#include "http_def.h"

uint16_t Daily_C_Curve[VALID_CURVE_POINT_NUM + 3] = {0}; 
uint16_t Daily_D_Curve[VALID_CURVE_POINT_NUM + 3] = {0}; 
uint32_t Daily_Column[VALID_HOUR_NUM*2 + 3]       = {0}; 
uint32_t Monthly_Column[VALID_DAY_NUM*2 + 3]      = {0}; 
uint32_t Yearly_Column[VALID_MONTH_NUM*2 + 3]     = {0};
uint32_t Total_Column[VALID_YEAR_NUM*2 + 3]       = {0};
struct h_resource h_Rsc[]={//html资源数组
	{h_000,sizeof(h_000)},
	{h_001,sizeof(h_001)},
	{h_002,sizeof(h_002)},
	{h_003,sizeof(h_003)},
	{h_004,sizeof(h_004)},
	{h_005,sizeof(h_005)},
	{h_006,sizeof(h_006)},
	{h_007,sizeof(h_007)},
	{h_008,sizeof(h_008)},
	{h_009,sizeof(h_009)},
	{h_010,sizeof(h_010)},
	{h_011,sizeof(h_011)},
	{h_012,sizeof(h_012)},
	{h_013,sizeof(h_013)},
	{h_014,sizeof(h_014)},
	{h_015,sizeof(h_015)},
	{h_016,sizeof(h_016)},
	{h_017,sizeof(h_017)},
	{h_018,sizeof(h_018)},
	{h_019,sizeof(h_019)},
	{h_020,sizeof(h_020)},
	{h_021,sizeof(h_021)},
	{h_022,sizeof(h_022)},
	{h_023,sizeof(h_023)},
	{h_024,sizeof(h_024)},
	{h_025,sizeof(h_025)}
};
struct j_resource j_Rsc[]={//javascript资源数组
	{j_000,sizeof(j_000)},
	{j_001,sizeof(j_001)},
	{j_002,sizeof(j_002)},
	{j_003,sizeof(j_003)},
	{j_004,sizeof(j_004)},
	{j_005,sizeof(j_005)},
	{j_006,sizeof(j_006)}
};
struct c_resource c_Rsc[]={//css资源数组
	{c_000,sizeof(c_000)}
};
struct i_resource i_Rsc[]={//图片资源数组
	{i_000,sizeof(i_000)},
	{i_001,sizeof(i_001)},
	{i_002,sizeof(i_002)},
	{i_003,sizeof(i_003)},
	{i_004,sizeof(i_004)},
	{i_005,sizeof(i_005)},
	{i_006,sizeof(i_006)},
	{i_007,sizeof(i_007)},
	{i_008,sizeof(i_008)},
	{i_009,sizeof(i_009)},
	{i_010,sizeof(i_010)},
	{i_011,sizeof(i_011)},
	{i_012,sizeof(i_012)},
	{i_013,sizeof(i_013)},
	{i_014,sizeof(i_014)},
	{i_015,sizeof(i_015)},
	{i_016,sizeof(i_016)},
	{i_017,sizeof(i_017)},
	{i_018,sizeof(i_018)},
	{i_019,sizeof(i_019)},
	{i_020,sizeof(i_020)},
	{i_021,sizeof(i_021)},
	{i_022,sizeof(i_022)},
	{i_023,sizeof(i_023)}
};
struct s_resource s_Rsc[]={//初始化数据缓冲区
	{s_000,sizeof(s_000)}
};
struct a_resource a_Rsc[]={//ajax返回确认
	{a_000,sizeof(a_000)}
};
struct p_resource p_Rsc[]={//用于导出配置文件、历史记录、曲线图、柱状图、历史发电量
	{p_000,sizeof(p_000)}
};

void webserver_2s_time_callback(void)							//2s回调
{
	if(loginFlag!=0)//心跳包计数
	{
		loginFlag--;//计数减一
	}
	if(loginFlag2!=0)
	{
		loginFlag2--;//计数减一
	}
}
uint32_t return_max_u32(uint32_t *arr,uint8_t k,uint8_t num)	//返回32位无符号数中，最大的数
{
    uint32_t max=arr[k];
    for(uint16_t i=k;i<num;i++)
    {
        if(max<arr[i])
        {
            max=arr[i];
        }
    }
    if(max==0)return 100;
    else return (((max-1)/100)+1)*100;
}
void set_param(uint16_t num, uint16_t id, uint16_t val) 		//设置参数数组的保存值
{
    Param_flag[num]=id;
    Param_value[num]=val;
    save_flag_int=1;
}
uint16_t do_save_data_int(uint16_t id,uint16_t U16_Val)			//设置参数
{
	int16_t S16_Val = (int16_t)U16_Val;
    switch(id)
    {   
		case 0x001F: //当前显示的PCS序号
			if(U16_Val <= EMS_Info.EMS4x.AGC_Info.SysParameter.Total_PCS_Number &&
				U16_Val > 0)
			{
				Cur_PCS_Num=U16_Val;
			}
		break;
		case 0x0040: //当前显示的PVS序号
			if(U16_Val <= PVS_NUM && U16_Val > 0)
			{
				Cur_PVS_Num=U16_Val;
			}
		break;	
		case 0x0050: //当前显示的BMS序号
			if(U16_Val <= EMS_Info.EMS4x.AGC_Info.SysParameter.Total_BMS_Number && U16_Val > 0)
			{
				Cur_BMS_Num=U16_Val;
			}
		break;
		case 0x0070: //当前显示的DCDC序号
			if(U16_Val <= EMS_Info.EMS4x.AGC_Info.SysParameter.Total_DCDC_Number && U16_Val > 0)
			{
				Cur_DCDC_Num=U16_Val;
			}
		break;				
		case 0x0130: //当前显示的PV序号
			if(U16_Val <= EMS_Info.EMS4x.AGC_Info.SysParameter.Total_PV_Number &&
				U16_Val > 0)
			{
				Cur_PV_Num=U16_Val;
			}
		break;
		case 0x0157://IP地址[0]
			if(U16_Val <= 255)
			{
				System_Info.Net.ip[0] = (uint8_t)U16_Val;
				(void)write_eeprom(NET_IP_0_ADDRESS, &System_Info.Net.ip[0], 1);
				Com_Data.Touch_Set_Net_Flag = true;
			}
		break;
		case 0x0158://IP地址[1]
			if(U16_Val <= 255)
			{
				System_Info.Net.ip[1] = (uint8_t)U16_Val;
				(void)write_eeprom(NET_IP_1_ADDRESS, &System_Info.Net.ip[1], 1);
				Com_Data.Touch_Set_Net_Flag = true;
			}
		break;
		case 0x0159://IP地址[2]
			if(U16_Val <= 255)
			{
				System_Info.Net.ip[2] = (uint8_t)U16_Val;
				(void)write_eeprom(NET_IP_2_ADDRESS, &System_Info.Net.ip[2], 1);
				Com_Data.Touch_Set_Net_Flag = true;
			}
		break;
		case 0x015A://IP地址[3]
			if(U16_Val <= 255)
			{
				System_Info.Net.ip[3] = (uint8_t)U16_Val;
				(void)write_eeprom(NET_IP_3_ADDRESS, &System_Info.Net.ip[3], 1);
				Com_Data.Touch_Set_Net_Flag = true;
			}
		break;
		case 0x015B://子网掩码[0]
			if(U16_Val <= 255)
			{
				System_Info.Net.submask[0] = (uint8_t)U16_Val;
				(void)write_eeprom(NET_SUBMASK_0_ADDRESS, &System_Info.Net.submask[0], 1);
				Com_Data.Touch_Set_Net_Flag = true;
			}
		break;
		case 0x015C://子网掩码[1]
			if(U16_Val <= 255)
			{
				System_Info.Net.submask[1] = (uint8_t)U16_Val;
				(void)write_eeprom(NET_SUBMASK_1_ADDRESS, &System_Info.Net.submask[1], 1);
				Com_Data.Touch_Set_Net_Flag = true;
			}
		break;
		case 0x015D://子网掩码[2]
			if(U16_Val <= 255)
			{
				System_Info.Net.submask[2] = (uint8_t)U16_Val;
				(void)write_eeprom(NET_SUBMASK_2_ADDRESS, &System_Info.Net.submask[2], 1);
				Com_Data.Touch_Set_Net_Flag = true;
			}
		break;
		case 0x015E://子网掩码[3]
			if(U16_Val <= 255)
			{
				System_Info.Net.submask[3] = (uint8_t)U16_Val;
				(void)write_eeprom(NET_SUBMASK_3_ADDRESS, &System_Info.Net.submask[3], 1);
				Com_Data.Touch_Set_Net_Flag = true;
			}
		break;
		case 0x015F://网关[0]
			if(U16_Val <= 255)
			{
				System_Info.Net.gateway[0] = (uint8_t)U16_Val;
				(void)write_eeprom(NET_GATEWAY_0_ADDRESS, &System_Info.Net.gateway[0], 1);
				Com_Data.Touch_Set_Net_Flag = true;
			}
		break;
		case 0x0160://网关[1]
			if(U16_Val <= 255)
			{
				System_Info.Net.gateway[1] = (uint8_t)U16_Val;
				(void)write_eeprom(NET_GATEWAY_1_ADDRESS, &System_Info.Net.gateway[1], 1);
				Com_Data.Touch_Set_Net_Flag = true;
			}
		break;
		case 0x0161://网关[2]
			if(U16_Val <= 255)
			{
				System_Info.Net.gateway[2] = (uint8_t)U16_Val;
				(void)write_eeprom(NET_GATEWAY_2_ADDRESS, &System_Info.Net.gateway[2], 1);
				Com_Data.Touch_Set_Net_Flag = true;
			}
		break;
		case 0x0162://网关[3]
			if(U16_Val <= 255)
			{
				System_Info.Net.gateway[3] = (uint8_t)U16_Val;
				(void)write_eeprom(NET_GATEWAY_3_ADDRESS, &System_Info.Net.gateway[3], 1);
				Com_Data.Touch_Set_Net_Flag = true;
			}
		break;
		case 0x0163://波特率
			if(1 <= U16_Val && U16_Val <= 4)
			{
				System_Info.Baud_Rate=(uint8_t)U16_Val;
				(void)write_eeprom(BAUD_RATE_ADDRESS, &System_Info.Baud_Rate, 1);
				uint16_t baudrate=0;
				switch(System_Info.Baud_Rate)
				{
					case 1:baudrate=4800;break;
					case 2:baudrate=9600;break;
					case 3:baudrate=19200;break;
					case 4:baudrate=38400;break;
				}
				(void)drv_ioctl(gt_glp.fserial1,USART_SET_BAUD,&baudrate);
			}
		break;			
		case 0x0164://上位机通讯地址
			if((1 <= U16_Val) && (U16_Val <= 247))
			{
				System_Info.Modbus_Address=(uint8_t)U16_Val;
				(void)write_eeprom(MODBUS_ADDRESS_ADDRESS, &System_Info.Modbus_Address, 1);
			}
		break;
		case 0x0165://端口号
			if((1 <= U16_Val) && (U16_Val <= UINT16_MAX) && (U16_Val != WEBSERVER_PORT) && (U16_Val != IEC104_PORT))
			{
				System_Info.Modbus_Port = U16_Val;
				(void)write_eeprom(NET_PORT_ADDRESS, &System_Info.Modbus_Port, 2);
				Com_Data.Touch_Set_Net_Flag = true;
			}
		break;
        case 0x0166://BMS通讯方式
			if((U16_Val==COM_BMS_MODE_CAN) || (U16_Val==COM_BMS_MODE_UART485) || (U16_Val==COM_BMS_MODE_NONE))
			{
// 				System_Info.IO_To_BMS_Mode=(uint8_t)U16_Val;
// 				(void)write_eeprom(IO_BMS_COM_MODE_ADDRESS, &System_Info.IO_To_BMS_Mode, 1);
// 				if((uint8_t)U16_Val==COM_BMS_MODE_NONE)
// 				{
// 					System_Info.BMS_Fault_Contact_Enabled = SWITCH_OFF;
// 					(void)write_eeprom(BMS_FAULT_CONTACT_ENABLED_ADDRESS, &System_Info.BMS_Fault_Contact_Enabled, 1);
// 					System_Info.BMS_Warning_Contact_Enabled = SWITCH_OFF;
// 					(void)write_eeprom(BMS_WARNING_CONTACT_ENABLED_ADDRESS, &System_Info.BMS_Warning_Contact_Enabled, 1);
// 				}
			}
		break;
        case 0x0167://BMS故障干接点使能
// 			if(System_Info.IO_To_BMS_Mode!=COM_BMS_MODE_NONE)
// 			{
// 				if((U16_Val == SWITCH_OFF) || (U16_Val == SWITCH_ON_OPEN) || (U16_Val == SWITCH_ON_CLOSE))
// 				{
// 					System_Info.BMS_Fault_Contact_Enabled = (uint8_t)U16_Val;
// 					(void)write_eeprom(BMS_FAULT_CONTACT_ENABLED_ADDRESS, &System_Info.BMS_Fault_Contact_Enabled, 1);
// 				}
// 			}
		break;
        case 0x0168://BMS告警干接点使能
// 			if(System_Info.IO_To_BMS_Mode!=COM_BMS_MODE_NONE)
// 			{
// 				if((U16_Val == SWITCH_OFF) || (U16_Val == SWITCH_ON_OPEN) || (U16_Val == SWITCH_ON_CLOSE))
// 				{
// 					System_Info.BMS_Warning_Contact_Enabled = (uint8_t)U16_Val;
// 					(void)write_eeprom(BMS_WARNING_CONTACT_ENABLED_ADDRESS, &System_Info.BMS_Warning_Contact_Enabled, 1);
// 				}
// 			}
		break;
		case 0x0169://BMS1通讯地址
// 			if((1 <= U16_Val) && (U16_Val <= 247))
// 			{
// 				System_Info.BMS_Address[0]=(uint8_t)U16_Val;
// 				(void)write_eeprom(BMS_ADDRESS_ADDRESS, &System_Info.BMS_Address, 1);
// 			}
		break;
		case 0x016A://IEC104通讯地址
			if((1 <= U16_Val) && (U16_Val <= 65535))
			{
				System_Info.IEC104_Address=U16_Val;
				(void)write_eeprom(IEC104_ADDRESS_ADDRESS, &System_Info.IEC104_Address, 2);
			}
		break;
		case 0x016B://IEC104超时时间T1
 			if((1 <= U16_Val) && (U16_Val < System_Info.IEC104_T3))
			{
				System_Info.IEC104_T1=U16_Val;
				(void)write_eeprom(IEC104_T1_ADDRESS, &System_Info.IEC104_T1, 2);
			}
		break;
		case 0x016C://IEC104超时时间T3
 			if((System_Info.IEC104_T1 < U16_Val) && (U16_Val <= 255))
			{
				System_Info.IEC104_T3=U16_Val;
				(void)write_eeprom(IEC104_T3_ADDRESS, &System_Info.IEC104_T3, 2);
			}
		break;
		case 0x016D://IEC104参数k
 			if((System_Info.IEC104_W<=((uint16_t)U16_Val*2/3))&&(U16_Val<=32767))
			{
				System_Info.IEC104_K = U16_Val;
				(void)write_eeprom(IEC104_K_ADDRESS,&System_Info.IEC104_K,2);
			}
		break;
		case 0x016E://IEC104参数w
 			if((1<=U16_Val)&&(U16_Val<=((uint16_t)System_Info.IEC104_K*2/3)))
			{
				System_Info.IEC104_W = U16_Val;
				(void)write_eeprom(IEC104_W_ADDRESS,&System_Info.IEC104_W,2);
			}
		break;
		case 0x016F://BMS2通讯地址
// 			if((1 <= U16_Val) && (U16_Val <= 247))
// 			{
// 				System_Info.BMS_Address[1]=(uint8_t)U16_Val;
// 				(void)write_eeprom(BMS_ADDRESS_ADDRESS, &System_Info.BMS_Address, 1);
// 			}
		break;			
        case 0x0170://系统时钟（年）
			if(2000<=U16_Val&&U16_Val<=2099)
			{
				Touch_Write_Time_Flag=true;
				Touch_Write_Time[0]=BinToBcd((uint8_t)(U16_Val-2000));
			}
		break;
        case 0x0171://系统时钟（月）
			if(U16_Val<=12)
			{
				Touch_Write_Time_Flag=true;
				Touch_Write_Time[1]=BinToBcd((uint8_t)U16_Val);
			}
		break;
        case 0x0172://系统时钟（日）
			if(U16_Val<=31)
			{
				Touch_Write_Time_Flag=true;
				Touch_Write_Time[2]=BinToBcd((uint8_t)U16_Val);
			}
		break;
        case 0x0173://系统时钟（时）
			if(U16_Val<=23)
			{
				Touch_Write_Time_Flag=true;
				Touch_Write_Time[3]=BinToBcd((uint8_t)U16_Val);
			}
		break;
        case 0x0174://系统时钟（分）
			if(U16_Val<=59)
			{
				Touch_Write_Time_Flag=true;
				Touch_Write_Time[4]=BinToBcd((uint8_t)U16_Val);
			}
		break;
		case 0x0175: //恒流充电电流
			if(SYS_NO_FAULT)
			{
			}
		break;
		case 0x0176: //恒压充电限流值
			if(SYS_NO_FAULT)
			{
				if((U16_Val>=EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_V_Mode_I_Min)&&
				   (U16_Val<=EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_V_Mode_I_Max))
				{
					EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_V_Mode_I = U16_Val;                        
					write_eeprom(CONST_V_MODE_I_VSG_ADDRESS,&EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_V_Mode_I,2);
				}  
			}
		break;
		case 0x0177://恒压充电电压
			if(SYS_NO_FAULT)
			{
				if((U16_Val>=EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_V_Mode_V_Min)&&
				   (U16_Val<=EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_V_Mode_V_Max))
				{
					EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_V_Mode_V = U16_Val;                        
					write_eeprom(CONST_V_MODE_V_VSG_ADDRESS,&EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_V_Mode_V,2);
				}			
			}
		break;
		case 0x0178: //恒DC功率充电功率
			if(SYS_NO_FAULT)
			{

			}
		break;
		case 0x0179: //恒AC功率充电功率
			if(SYS_NO_FAULT)
			{
				if((S16_Val>=EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_P_AC_Mode_P_Min)&&
				   (S16_Val<=EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_P_AC_Mode_P_Max))
				{            
					EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_P_AC_Mode_P = S16_Val;                        
					write_eeprom(CONST_P_AC_MODE_P_VSG_ADDRESS,&EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_P_AC_Mode_P,2);
				}
			}
		break;
		case 0x017A://恒流放电电流
			if(SYS_NO_FAULT)
			{
				
			}
		break;
		case 0x017B: //限压放电电压
			if(SYS_NO_FAULT)
			{

			}
		break;
		case 0x017C: //限压放电限制电流
			if(SYS_NO_FAULT)
			{

			}
		break;
		case 0x0180: //独立逆变电压
			if(SYS_NO_FAULT)
			{

			}	
		break;
		case 0x0181: //独立逆变频率
			if(SYS_NO_FAULT)
			{

			}	
		break;
		case 0x0182://无缝切换功能开关
			if(U16_Val==1)
			{
				System_Info.VSG_func_enable=1; // 1-vsg模式
				//Sys_Ctrl.VSG_Mode = true; //屏下发切换时不启动
			}
			else
			{
				System_Info.VSG_func_enable=0; // 0-并网模式
				//Sys_Ctrl.OnGrid_Mode=true; //屏下发切换时不启动
			}
			write_eeprom(VSG_FUNC_ENABLE_ADDRESS,&System_Info.VSG_func_enable,1);
		break;
		case 0x0184:
			if(SYS_NO_FAULT)
			{
				if((U16_Val==QP)||(U16_Val==PF)||(U16_Val==SHUT_OFF))
				{
					if(U16_Val==0)
					{
						EMS_Info.EMS4x.AGC_Info.SysParameter.Qvar_Adj_Mode=SHUT_OFF;
					}
					else if(U16_Val==1)
					{
						EMS_Info.EMS4x.AGC_Info.SysParameter.Qvar_Adj_Mode=PF;
					}						
					else if(U16_Val==2)
					{
						EMS_Info.EMS4x.AGC_Info.SysParameter.Qvar_Adj_Mode=QP;
					}						
					write_eeprom(EMS_RUN_Q_ADJ_MODE_ADDRESS, &EMS_Info.EMS4x.AGC_Info.SysParameter.Qvar_Adj_Mode, 2);

					if(SHUT_OFF==EMS_Info.EMS4x.AGC_Info.SysParameter.Qvar_Adj_Mode)
					{                    
						EMS_Info.EMS4x.AGC_Info.SysParameter.EMS_Run_Q_Set=0; // caoxh
						EMS_Info.EMS4x.AGC_Info.SysParameter.Power_Factor=P_Range[PCS_Power_Type].Power_Factor.Dft; // caoxh                           
						write_eeprom(EMS_RUN_P_FACTOR_SET_VALUE_ADDRESS, &EMS_Info.EMS4x.AGC_Info.SysParameter.Power_Factor, 2);
						write_eeprom(EMS_RUN_Q_SET_VALUE_ADDRESS, &EMS_Info.EMS4x.AGC_Info.SysParameter.EMS_Run_Q_Set, 2);
					}
					else if(PF==EMS_Info.EMS4x.AGC_Info.SysParameter.Qvar_Adj_Mode)
					{
						 EMS_Info.EMS4x.AGC_Info.SysParameter.EMS_Run_Q_Set=0; // caoxh
						 write_eeprom(EMS_RUN_Q_SET_VALUE_ADDRESS, &EMS_Info.EMS4x.AGC_Info.SysParameter.EMS_Run_Q_Set, 2);
					}
					else if(QP==EMS_Info.EMS4x.AGC_Info.SysParameter.Qvar_Adj_Mode)
					{
						EMS_Info.EMS4x.AGC_Info.SysParameter.Power_Factor=P_Range[PCS_Power_Type].Power_Factor.Dft; // caoxh
						write_eeprom(EMS_RUN_P_FACTOR_SET_VALUE_ADDRESS, &EMS_Info.EMS4x.AGC_Info.SysParameter.Power_Factor, 2);                            
					}         

					for(uint8_t i=0;i<EMS_Info.EMS4x.AGC_Info.SysParameter.Total_PCS_Number;i++)
					{
						//PCS_Info[i].PCS4x.RControl.Qvar_Adj_Mode=EMS_Info.EMS4x.AGC_Info.SysParameter.Power_Factor;
						PCS_Info[i].PCS4x.RControl.Qvar_Adj_Mode=EMS_Info.EMS4x.AGC_Info.SysParameter.Qvar_Adj_Mode;
						PCS_Ctrl_Data[i].Power_Factor=EMS_Info.EMS4x.AGC_Info.SysParameter.Power_Factor;
						Send_Data_To_PCS_0x10_02[i]=true;
					}
				}
			}
		break;
		case 0x0185://功率因数
			if(SYS_NO_FAULT)
			{
				if(EMS_Info.EMS4x.AGC_Info.SysParameter.Qvar_Adj_Mode==PF)
				{
					if(((abs((int16_t)U16_Val))>=P_Range[PCS_Power_Type].Power_Factor.Min) && ((abs((int16_t)U16_Val))<=P_Range[PCS_Power_Type].Power_Factor.Max))
					{
						EMS_Info.EMS4x.AGC_Info.SysParameter.Power_Factor=(int16_t)U16_Val;							
						write_eeprom(EMS_RUN_P_FACTOR_SET_VALUE_ADDRESS, &EMS_Info.EMS4x.AGC_Info.SysParameter.Power_Factor, 2);
						
						EMS_Info.EMS4x.AGC_Info.SysParameter.EMS_Run_Q_Set=0; // caoxh
						write_eeprom(EMS_RUN_Q_SET_VALUE_ADDRESS, &EMS_Info.EMS4x.AGC_Info.SysParameter.EMS_Run_Q_Set, 2);
						
						for(uint8_t i=0;i<EMS_Info.EMS4x.AGC_Info.SysParameter.Total_PCS_Number;i++)
						{
							PCS_Ctrl_Data[i].Power_Factor=EMS_Info.EMS4x.AGC_Info.SysParameter.Power_Factor;
							Send_Data_To_PCS_0x10_02[i]=true;
						}
					}
				}
			}
		break;
		case 0x0187: //并网模式设置
			if(SYS_NO_FAULT)
			{
				if(U16_Val==0 || U16_Val==1|| U16_Val==2)
				{
					OnGrid_Run_Mode=(uint8_t)U16_Val;
					write_eeprom(ONGRID_RUN_MODE_VSG_ADDRESS,&OnGrid_Run_Mode,2);
				}
			}	
		break;
		case 0x0188:	//离网主被动模式设置
			if(SYS_NO_FAULT)
			{
				if(U16_Val==0 || U16_Val==1)
				{
					EMS_Start_Type=(uint8_t)U16_Val;
					write_eeprom(EMS_START_TYPE_ADDRESS, &EMS_Start_Type, 1);			
				}
			}
		break;
		case 0x0189:	//离网模式设置
			if(SYS_NO_FAULT)
			{
				if(U16_Val==START_COMMAND)
				{
					Sys_Ctrl.Sys_Start=true;
				}
				if(U16_Val==STOP_COMMAND)
				{
					Sys_Ctrl.Manual_Stop=true;
				}
			}
		break;
		case  0x018A:	//并网运行功率给定
			if(SYS_NO_FAULT)
			{
			}
		break;
		case 0x018C:	//VSG输出电压给定值
			if(SYS_NO_FAULT)
			{
				if(U16_Val>=VSG_Range[VSG_U0].Min&&U16_Val<=VSG_Range[VSG_U0].Max)
				{
					VSG_Para.VSG_u0_set = U16_Val;
					write_eeprom(VSG_U0_VALUE_ADDRESS,&VSG_Para.VSG_u0_set,2);
					Send_Data_To_PCS_Broadcast = true;
				}
			}
		break;
		case 0x018D:	//VSG输出频率给定值
			if(SYS_NO_FAULT)
			{
				if(U16_Val>=VSG_Range[VSG_W0].Min&&U16_Val<=VSG_Range[VSG_W0].Max)
				{
					VSG_Para.VSG_w0_set = U16_Val;
					write_eeprom(VSG_W0_VALUE_ADDRESS,&VSG_Para.VSG_w0_set,2);
					Send_Data_To_PCS_Broadcast = true;
				}
			}
		break;
		case 0x018E:		//有功下垂控制系数
			if(SYS_NO_FAULT)
			{
				if(U16_Val>=VSG_Range[VSG_P_DOWN_CONTROL_RATIO].Min&&U16_Val<=VSG_Range[VSG_P_DOWN_CONTROL_RATIO].Max)
				{
					VSG_Para.VSG_P_down_control_ratio = U16_Val;
					write_eeprom(VSG_P_DOWN_CONTROL_RATIO_ADDRESS,&VSG_Para.VSG_P_down_control_ratio,2);
					Send_Data_To_PCS_Broadcast = true;
				}
			}
		break;
		case 0x018F:		//无功下垂控制系数
			if(SYS_NO_FAULT)
			{
				if(U16_Val>=VSG_Range[VSG_Q_DOWN_CONTROL_RATIO].Min&&U16_Val<=VSG_Range[VSG_Q_DOWN_CONTROL_RATIO].Max)
				{
					VSG_Para.VSG_Q_down_control_ratio= U16_Val;
					write_eeprom(VSG_Q_DOWN_CONTROL_RATIO_ADDRESS,&VSG_Para.VSG_Q_down_control_ratio,2);
					Send_Data_To_PCS_Broadcast = true;
				}
			}
		break;
		case 0x0190:		//二次调频给定值
			if(SYS_NO_FAULT)
			{
				int16_t temp=(int16_t)U16_Val;
				if(temp>=VSG_Range[VSG_PREF].Min && temp<=VSG_Range[VSG_PREF].Max)
				{
					VSG_Para.VSG_Pref_set = temp;
					write_eeprom(VSG_PREF_VALUE_ADDRESS,&VSG_Para.VSG_Pref_set,2);
				}
			}
		break;
		case 0x0191:		//无功下发给定值
			if(SYS_NO_FAULT)
			{
				int16_t temp=(int16_t)U16_Val;
				if(temp>=VSG_Range[VSG_QREF].Min&&temp<=VSG_Range[VSG_QREF].Max)
				{
					VSG_Para.VSG_Qref_set = temp;
					write_eeprom(VSG_QREF_VALUE_ADDRESS,&VSG_Para.VSG_Qref_set,2);
				}
			}
		break;
		case 0x0208: //恢复出厂值
			if(U16_Val == 0x55 && Com_Data.Load_Default_Flag != 0xAA)
			{
				Com_Data.Load_Default_Flag = 0xAA;
			}
		break;	
        case 0x0301://页面语言
			if(U16_Val == CHINESE || U16_Val == ENGLISH)
			{
				Webserver_Language = (uint8_t)U16_Val;
				(void)write_eeprom(WEBSERVER_LANGUAGE_ADDRESS, &Webserver_Language, 1);
			}
		break;
		case 0x0380://协议类型
			if(U16_Val==NEW_PROTOCOL || U16_Val==OLD_PROTOCOL)
			{
				System_Info.PCS_Protocol_Type=(uint8_t)U16_Val;
				write_eeprom(PCS_PROTOCOL_TYPE_ADDRESS, &System_Info.PCS_Protocol_Type, 1);
			}			
		break;
		case 0x0381://母线类型
			if(U16_Val==0 || U16_Val==1)
			{
				Bus_Type=(uint8_t)U16_Val;
				write_eeprom(BUS_TYPE_ADDRESS, &Bus_Type, 1);			
			}
		break;
		case 0x0382://是否并网
			if(U16_Val==0 || U16_Val==1)
			{
				Grid_Connect_Type=(uint8_t)U16_Val;
				write_eeprom(GRID_CONNECT_TYPE_ADDRESS, &Grid_Connect_Type, 1);			
			}
		break;
		case 0x0383://直流母线充电使能
			if(U16_Val==0 || U16_Val==1)
			{
				DC_Bus_Charge_Permit=(uint8_t)U16_Val;
				write_eeprom(DC_BUS_CHARGE_PERMIT_ADDRESS, &DC_Bus_Charge_Permit, 1);			
			}			
		break;
		case 0x0384://系统功率设置
			if(U16_Val>SYS_POWER_SET_MIN && U16_Val<=SYS_POWER_SET_MAX)
			{
				System_Power_Set=U16_Val;
				write_eeprom(SYS_POWER_SET_ADDRESS, &System_Power_Set, 2);			
			}
		break;
		case 0x0385://储能逆变器型号
			if(U16_Val<PCS_Power_Max && U16_Val!=PCS_Power_Type)
			{
				PCS_Power_Type=U16_Val;
				Com_Data.Load_Default_Flag = 0xAA;//设置完需回复出厂设置
				write_eeprom(SYS_PCS_POWER_TYPE_ADDRESS, &PCS_Power_Type, 1);
			}
		break;
		case 0x0386://DCDC型号
			if(U16_Val==0 || U16_Val==1)
			{
				DCDC_Type=(uint8_t)U16_Val;
				write_eeprom(SYS_DCDC_TYPE_ADDRESS, &DCDC_Type, 1);						
			}			
		break;
		case 0x0387://优先级选择
			if(U16_Val==0 || U16_Val==1)
			{
				EMS_Run_Mode=(uint8_t)U16_Val;
				write_eeprom(EMS_RUN_MODE_ADDRESS, &EMS_Run_Mode, 1);						
			}
		break;
		case 0x0388://VSG使能
			if(U16_Val==1)
			{
				System_Info.VSG_func_enable=1; // 1-vsg模式
				//Sys_Ctrl.VSG_Mode = true; //屏下发切换时不启动
			}
			else
			{
				System_Info.VSG_func_enable=0; // 0-并网模式
				//Sys_Ctrl.OnGrid_Mode=true; //屏下发切换时不启动
			}
			write_eeprom(VSG_FUNC_ENABLE_ADDRESS,&System_Info.VSG_func_enable,1);
		break;
		case 0x0389://分时段控制使能
			if(U16_Val==0 || U16_Val==1)
			{
				System_Info.Time_Slot_Enable=(uint8_t)U16_Val;
				//write_eeprom(xxx, &System_Info.Time_Slot_Enable, 1);						
			}
		break;			
		case 0x0390://web是否显示pcs界面
			if(U16_Val==0 || U16_Val==1)
			{
				webPageShow.pcs=(uint8_t)U16_Val;
				write_eeprom(WEB_PAGE_PCS_ST_ADDRESS, &webPageShow.pcs, 1);						
			}
		break;
		case 0x0391://web是否显示pv界面
			if(U16_Val==0 || U16_Val==1)
			{
				webPageShow.pv=(uint8_t)U16_Val;
				write_eeprom(WEB_PAGE_PV_ST_ADDRESS, &webPageShow.pv, 1);						
			}
		break;
		case 0x0392://web是否显示dcdc界面
			if(U16_Val==0 || U16_Val==1)
			{
				webPageShow.dcdc=(uint8_t)U16_Val;
				write_eeprom(WEB_PAGE_DCDC_ST_ADDRESS, &webPageShow.dcdc, 1);						
			}
		break;
		case 0x0393://web是否显示pvs界面
			if(U16_Val==0 || U16_Val==1)
			{
				webPageShow.pvs=(uint8_t)U16_Val;
				write_eeprom(WEB_PAGE_PVS_ST_ADDRESS, &webPageShow.pvs, 1);						
			}
		break;
		case 0x0394://web是否显示bms界面
			if(U16_Val==0 || U16_Val==1)
			{
				webPageShow.bms=(uint8_t)U16_Val;
				write_eeprom(WEB_PAGE_BMS_ST_ADDRESS, &webPageShow.bms, 1);						
			}
		break;
		case 0x0395://web是否显示ammeter界面
			if(U16_Val==0 || U16_Val==1)
			{
				webPageShow.ammeter=(uint8_t)U16_Val;
				write_eeprom(WEB_PAGE_AMMETER_ST_ADDRESS, &webPageShow.ammeter, 1);						
			}
		break;
		case 0x0396://web是否显示实时监控界面
			if(U16_Val==0 || U16_Val==1)
			{
				webPageShow.realtimeMonitor=(uint8_t)U16_Val;
				write_eeprom(WEB_PAGE_REALTIMEMONITOR_ST_ADDRESS, &webPageShow.realtimeMonitor, 1);	
			}
		break;
		case 0x0503://时间段1起始时间:时
			if(U16_Val>=0 || U16_Val<=23)
			{
				time_slot[0].st_hour=U16_Val;
			}
		break;
		case 0x0504://时间段1起始时间:分
			if(U16_Val>=0 || U16_Val<=59)
			{
				time_slot[0].st_min=U16_Val;
			}
		break;
		case 0x0508://时间段1结束时间:时
			if(U16_Val>=0 || U16_Val<=23)
			{
				time_slot[0].end_hour=U16_Val;
			}
		break;
		case 0x0509://时间段1结束时间:分
			if(U16_Val>=0 || U16_Val<=59)
			{
				time_slot[0].end_min=U16_Val;
			}
		break;
		case 0x050A://时间段1运行模式
			if(U16_Val>=0 || U16_Val<=2)
			{
				time_slot[0].running_mode=U16_Val;
			}
		break;
		case 0x050B://时间段1控制模式
			if(U16_Val>=0 || U16_Val<=4)
			{
				time_slot[0].ctrl_mode=U16_Val;
			}
		break;
		case 0x050C://时间段1运行功率
			if(U16_Val>=0 || U16_Val<=1000)
			{
				time_slot[0].power=U16_Val;
			}
		break;		
		case 0x0513://时间段2起始时间:时
			if(U16_Val>=0 || U16_Val<=23)
			{
				time_slot[1].st_hour=U16_Val;
			}
		break;			
		case 0x0514://时间段2起始时间:分
			if(U16_Val>=0 || U16_Val<=59)
			{
				time_slot[1].st_min=U16_Val;
			}
		break;
		case 0x0518://时间段2结束时间:时
			if(U16_Val>=0 || U16_Val<=23)
			{
				time_slot[1].end_hour=U16_Val;
			}
		break;
		case 0x0519://时间段2结束时间:分
			if(U16_Val>=0 || U16_Val<=59)
			{
				time_slot[1].end_min=U16_Val;
			}
		break;
		case 0x051A://时间段2运行模式
			if(U16_Val>=0 || U16_Val<=2)
			{
				time_slot[1].running_mode=U16_Val;
			}
		break;
		case 0x051B://时间段2控制模式
			if(U16_Val>=0 || U16_Val<=4)
			{
				time_slot[1].ctrl_mode=U16_Val;
			}
		break;
		case 0x051C://时间段2运行功率
			if(U16_Val>=0 || U16_Val<=1000)
			{
				time_slot[1].power=U16_Val;
			}
		break;		
		case 0x0523://时间段3起始时间:时
			if(U16_Val>=0 || U16_Val<=23)
			{
				time_slot[2].st_hour=U16_Val;
			}
		break;
		case 0x0524://时间段3起始时间:分
			if(U16_Val>=0 || U16_Val<=59)
			{
				time_slot[2].st_min=U16_Val;
			}
		break;
		case 0x0528://时间段3结束时间:时
			if(U16_Val>=0 || U16_Val<=23)
			{
				time_slot[2].end_hour=U16_Val;
			}
		break;
		case 0x0529://时间段3结束时间:分
			if(U16_Val>=0 || U16_Val<=59)
			{
				time_slot[2].end_min=U16_Val;
			}
		break;
		case 0x052A://时间段3运行模式
			if(U16_Val>=0 || U16_Val<=2)
			{
				time_slot[2].running_mode=U16_Val;
			}
		break;
		case 0x052B://时间段3控制模式
			if(U16_Val>=0 || U16_Val<=4)
			{
				time_slot[2].ctrl_mode=U16_Val;
			}
		break;
		case 0x052C://时间段3运行功率
			if(U16_Val>=0 || U16_Val<=1000)
			{
				time_slot[2].power=U16_Val;
			}
		break;	
		case 0x0533://时间段4起始时间:时
			if(U16_Val>=0 || U16_Val<=23)
			{
				time_slot[3].st_hour=U16_Val;
			}
		break;
		case 0x0534://时间段4起始时间:分
			if(U16_Val>=0 || U16_Val<=59)
			{
				time_slot[3].st_min=U16_Val;
			}
		break;
		case 0x0538://时间段4结束时间:时
			if(U16_Val>=0 || U16_Val<=23)
			{
				time_slot[3].end_hour=U16_Val;
			}
		break;
		case 0x0539://时间段4结束时间:分
			if(U16_Val>=0 || U16_Val<=59)
			{
				time_slot[3].end_min=U16_Val;
			}
		break;
		case 0x053A://时间段4运行模式
			if(U16_Val>=0 || U16_Val<=2)
			{
				time_slot[3].running_mode=U16_Val;
			}
		break;
		case 0x053B://时间段4控制模式
			if(U16_Val>=0 || U16_Val<=4)
			{
				time_slot[3].ctrl_mode=U16_Val;
			}
		break;
		case 0x053C://时间段4运行功率
			if(U16_Val>=0 || U16_Val<=1000)
			{
				time_slot[3].power=U16_Val;
			}
		break;	
		case 0x0543://时间段5起始时间:时
			if(U16_Val>=0 || U16_Val<=23)
			{
				time_slot[4].st_hour=U16_Val;
			}
		break;
		case 0x0544://时间段5起始时间:分
			if(U16_Val>=0 || U16_Val<=59)
			{
				time_slot[4].st_min=U16_Val;
			}
		break;
		case 0x0548://时间段5结束时间:时
			if(U16_Val>=0 || U16_Val<=23)
			{
				time_slot[4].end_hour=U16_Val;
			}
		break;
		case 0x0549://时间段5结束时间:分
			if(U16_Val>=0 || U16_Val<=59)
			{
				time_slot[4].end_min=U16_Val;
			}
		break;
		case 0x054A://时间段5运行模式
			if(U16_Val>=0 || U16_Val<=2)
			{
				time_slot[4].running_mode=U16_Val;
			}
		break;
		case 0x054B://时间段5控制模式
			if(U16_Val>=0 || U16_Val<=4)
			{
				time_slot[4].ctrl_mode=U16_Val;
			}
		break;
		case 0x054C://时间段5运行功率
			if(U16_Val>=0 || U16_Val<=1000)
			{
				time_slot[4].power=U16_Val;
			}
		break;	

		case 0x0553://时间段6起始时间:时
			if(U16_Val>=0 || U16_Val<=23)
			{
				time_slot[5].st_hour=U16_Val;
			}
		break;
		case 0x0554://时间段6起始时间:分
			if(U16_Val>=0 || U16_Val<=59)
			{
				time_slot[5].st_min=U16_Val;
			}
		break;
		case 0x0558://时间段6结束时间:时
			if(U16_Val>=0 || U16_Val<=23)
			{
				time_slot[5].end_hour=U16_Val;
			}
		break;
		case 0x0559://时间段6结束时间:分
			if(U16_Val>=0 || U16_Val<=59)
			{
				time_slot[5].end_min=U16_Val;
			}
		break;
		case 0x055A://时间段6运行模式
			if(U16_Val>=0 || U16_Val<=2)
			{
				time_slot[5].running_mode=U16_Val;
			}
		break;
		case 0x055B://时间段6控制模式
			if(U16_Val>=0 || U16_Val<=4)
			{
				time_slot[5].ctrl_mode=U16_Val;
			}
		break;
		case 0x055C://时间段6运行功率
			if(U16_Val>=0 || U16_Val<=1000)
			{
				time_slot[5].power=U16_Val;
			}
		break;		

		case 0x0563://时间段7起始时间:时
			if(U16_Val>=0 || U16_Val<=23)
			{
				time_slot[6].st_hour=U16_Val;
			}
		break;
		case 0x0564://时间段7起始时间:分
			if(U16_Val>=0 || U16_Val<=59)
			{
				time_slot[6].st_min=U16_Val;
			}
		break;
		case 0x0568://时间段7结束时间:时
			if(U16_Val>=0 || U16_Val<=23)
			{
				time_slot[6].end_hour=U16_Val;
			}
		break;
		case 0x0569://时间段7结束时间:分
			if(U16_Val>=0 || U16_Val<=59)
			{
				time_slot[6].end_min=U16_Val;
			}
		break;
		case 0x056A://时间段7运行模式
			if(U16_Val>=0 || U16_Val<=2)
			{
				time_slot[6].running_mode=U16_Val;
			}
		break;
		case 0x056B://时间段7控制模式
			if(U16_Val>=0 || U16_Val<=4)
			{
				time_slot[6].ctrl_mode=U16_Val;
			}
		break;
		case 0x056C://时间段7运行功率
			if(U16_Val>=0 || U16_Val<=1000)
			{
				time_slot[6].power=U16_Val;
			}
		break;	

		case 0x0573://时间段8起始时间:时
			if(U16_Val>=0 || U16_Val<=23)
			{
				time_slot[7].st_hour=U16_Val;
			}
		break;
		case 0x0574://时间段8起始时间:分
			if(U16_Val>=0 || U16_Val<=59)
			{
				time_slot[7].st_min=U16_Val;
			}
		break;
		case 0x0578://时间段8结束时间:时
			if(U16_Val>=0 || U16_Val<=23)
			{
				time_slot[7].end_hour=U16_Val;
			}
		break;
		case 0x0579://时间段8结束时间:分
			if(U16_Val>=0 || U16_Val<=59)
			{
				time_slot[7].end_min=U16_Val;
			}
		break;
		case 0x057A://时间段8运行模式
			if(U16_Val>=0 || U16_Val<=2)
			{
				time_slot[7].running_mode=U16_Val;
			}
		break;
		case 0x057B://时间段8控制模式
			if(U16_Val>=0 || U16_Val<=4)
			{
				time_slot[7].ctrl_mode=U16_Val;
			}
		break;
		case 0x057C://时间段8运行功率
			if(U16_Val>=0 || U16_Val<=1000)
			{
				time_slot[7].power=U16_Val;
			}
		break;

		case 0x0583://时间段9起始时间:时
			if(U16_Val>=0 || U16_Val<=23)
			{
				time_slot[8].st_hour=U16_Val;
			}
		break;
		case 0x0584://时间段9起始时间:分
			if(U16_Val>=0 || U16_Val<=59)
			{
				time_slot[8].st_min=U16_Val;
			}
		break;
		case 0x0588://时间段9结束时间:时
			if(U16_Val>=0 || U16_Val<=23)
			{
				time_slot[8].end_hour=U16_Val;
			}
		break;
		case 0x0589://时间段9结束时间:分
			if(U16_Val>=0 || U16_Val<=59)
			{
				time_slot[8].end_min=U16_Val;
			}
		break;
		case 0x058A://时间段9运行模式
			if(U16_Val>=0 || U16_Val<=2)
			{
				time_slot[8].running_mode=U16_Val;
			}
		break;
		case 0x058B://时间段9控制模式
			if(U16_Val>=0 || U16_Val<=4)
			{
				time_slot[8].ctrl_mode=U16_Val;
			}
		break;
		case 0x058C://时间段9运行功率
			if(U16_Val>=0 || U16_Val<=1000)
			{
				time_slot[8].power=U16_Val;
			}
		break;	
		case 0x0593://时间段10起始时间:时
			if(U16_Val>=0 || U16_Val<=23)
			{
				time_slot[9].st_hour=U16_Val;
			}
		break;
		case 0x0594://时间段10起始时间:分
			if(U16_Val>=0 || U16_Val<=59)
			{
				time_slot[9].st_min=U16_Val;
			}
		break;
		case 0x0598://时间段10结束时间:时
			if(U16_Val>=0 || U16_Val<=23)
			{
				time_slot[9].end_hour=U16_Val;
			}
		break;
		case 0x0599://时间段10结束时间:分
			if(U16_Val>=0 || U16_Val<=59)
			{
				time_slot[9].end_min=U16_Val;
			}
		break;
		case 0x059A://时间段10运行模式
			if(U16_Val>=0 || U16_Val<=2)
			{
				time_slot[9].running_mode=U16_Val;
			}
		break;
		case 0x059B://时间段10控制模式
			if(U16_Val>=0 || U16_Val<=4)
			{
				time_slot[9].ctrl_mode=U16_Val;
			}
		break;
		case 0x059C://时间段10运行功率
			if(U16_Val>=0 || U16_Val<=1000)
			{
				time_slot[9].power=U16_Val;
			}
		break;	
		case 0x05A3://时间段11起始时间:时
			if(U16_Val>=0 || U16_Val<=23)
			{
				time_slot[10].st_hour=U16_Val;
			}
		break;
		case 0x05A4://时间段11起始时间:分
			if(U16_Val>=0 || U16_Val<=59)
			{
				time_slot[10].st_min=U16_Val;
			}
		break;
		case 0x05A8://时间段11结束时间:时
			if(U16_Val>=0 || U16_Val<=23)
			{
				time_slot[10].end_hour=U16_Val;
			}
		break;
		case 0x05A9://时间段11结束时间:分
			if(U16_Val>=0 || U16_Val<=59)
			{
				time_slot[10].end_min=U16_Val;
			}
		break;
		case 0x05AA://时间段11运行模式
			if(U16_Val>=0 || U16_Val<=2)
			{
				time_slot[10].running_mode=U16_Val;
			}
		break;
		case 0x05AB://时间段11控制模式
			if(U16_Val>=0 || U16_Val<=4)
			{
				time_slot[10].ctrl_mode=U16_Val;
			}
		break;
		case 0x05AC://时间段11运行功率
			if(U16_Val>=0 || U16_Val<=1000)
			{
				time_slot[10].power=U16_Val;
			}
		break;
		case 0x05B3://时间段12起始时间:时
			if(U16_Val>=0 || U16_Val<=23)
			{
				time_slot[11].st_hour=U16_Val;
			}
		break;
		case 0x05B4://时间段12起始时间:分
			if(U16_Val>=0 || U16_Val<=59)
			{
				time_slot[11].st_min=U16_Val;
			}
		break;
		case 0x05B8://时间段12结束时间:时
			if(U16_Val>=0 || U16_Val<=23)
			{
				time_slot[11].end_hour=U16_Val;
			}
		break;
		case 0x05B9://时间段12结束时间:分
			if(U16_Val>=0 || U16_Val<=59)
			{
				time_slot[11].end_min=U16_Val;
			}
		break;
		case 0x05BA://时间段12运行模式
			if(U16_Val>=0 || U16_Val<=2)
			{
				time_slot[11].running_mode=U16_Val;
			}
		break;
		case 0x05BB://时间段12控制模式
			if(U16_Val>=0 || U16_Val<=4)
			{
				time_slot[11].ctrl_mode=U16_Val;
			}
		break;
		case 0x05BC://时间段12运行功率
			if(U16_Val>=0 || U16_Val<=1000)
			{
				time_slot[11].power=U16_Val;
			}
		break;				
        default:
        break;
    }
    return ~0;
}
uint32_t b[10];
uint32_t get_param_by_id(uint32_t addr, uint8_t id)
{
    uint32_t value = 0;
	
	if(addr > 0 && addr < 0x0020)
	{
		switch(addr)
		{  
			case 0x0002:value = 0;break;										
			case 0x0003:value = System_Power_Set*10;break;										
			case 0x0004:value = (uint32_t)DIN(GRID_CALL);break;											
			case 0x0005:value = EMS_Info.EMS3x.AGC_Info.RMeasure.PCS_Active_Power;break;												
			case 0x0006:value = EMS_Info.EMS3x.AGC_Info.RMeasure.PCS_Reactive_Power;break;															
			case 0x0007:value = EMS_Info.EMS3x.AGC_Info.RMeasure.PCS_Powerfactor;break;																
			case 0x0008:value = EMS_Info.EMS3x.AGC_Info.RMeasure.PV_Active_Power;break;															
			case 0x0009:value = EMS_Info.EMS3x.AGC_Info.RMeasure.PV_Reactive_Power;break;															
			case 0x000A:value = EMS_Info.EMS3x.AGC_Info.RMeasure.PV_Powerfactor;break;															
			case 0x000B:value = EMS_Info.EMS3x.AGC_Info.RMeasure.Load_Active_Power;break;															
			case 0x000C:value = EMS_Info.EMS3x.AGC_Info.RMeasure.Load_Reactive_Power;break;															
			case 0x000D:value = EMS_Info.EMS3x.AGC_Info.RMeasure.Load_Powerfactor;break;																
			case 0x000E:value = EMS_Info.EMS3x.EMS_Controller_Info.RMeasure.PCS_Total_Charge_Energy;break;															
			case 0x000F:value = EMS_Info.EMS3x.EMS_Controller_Info.RMeasure.PCS_Total_Discharge_Energy;break;																
			case 0x0010:value = EMS_Info.EMS3x.EMS_Controller_Info.RMeasure.PV_Total_Active_Energy;break;											
			case 0x0011:value = System_Run_Info.Total_Load_Energy;break;											
			case 0x0012:value = EMS_Info.EMS3x.AGC_Info.RMeasure.PCS_Online_Num;break;											
			case 0x0013:value = EMS_Info.EMS3x.AGC_Info.RMeasure.PV_Online_Num;break;												
			case 0x0014:value = EMS_Info.EMS4x.AGC_Info.SysParameter.PCS_Rated_Output_Power;break;												
			case 0x0015:value = EMS_Info.EMS4x.AGC_Info.SysParameter.PV_Rated_Output_Power;break;												
			case 0x0016:value = EMS_Info.EMS3x.AGC_Info.RMeasure.MG_Voltage;break;											
			case 0x0017:value = EMS_Info.EMS3x.AGC_Info.RMeasure.MG_Frequency;break;											
			case 0x0018:value = (uint32_t)DIN(GRID_CONTACTOR);break;										
			case 0x0019:value = (uint32_t)DIN(MGRID_CONTACTOR);break;										
			case 0x001A:value = EMS_Info.EMS4x.AGC_Info.SysParameter.Total_PCS_Number;break;									
			case 0x001B:value = EMS_Info.EMS4x.AGC_Info.SysParameter.Total_PV_Number;break;							
			case 0x001C:value = PVS_NUM;break;									
			case 0x001D:value = EMS_Info.EMS4x.AGC_Info.SysParameter.Total_DCDC_Number;break;								
			case 0x001E:value = EMS_Info.EMS4x.AGC_Info.SysParameter.Total_BMS_Number;break;								
			case 0x001F:value = Cur_PCS_Num;break;																	
		}
	}	
	else if(addr >= 0x0020 && addr <= 0x0031)		//储能逆变器信息
	{
		switch(addr)
		{  
			case 0x0020:value =PCS_Info[id].PCS3x.Rmeasure.DC_Voltage;break;//当前显示储能变流器直流电压
			case 0x0021:value =PCS_Info[id].PCS3x.Rmeasure.DC_Current;break;//当前显示储能变流器直流电流	
			case 0x0022:value =(uint32_t)PCS_Info[id].PCS3x.Rmeasure.DC_Power;break;//当前显示储能变流器直流功率
			case 0x0023:value =PCS_Info[id].PCS3x.Rmeasure.VAB;break;//当前显示储能变流器VAB
			case 0x0024:value =PCS_Info[id].PCS3x.Rmeasure.VBC;break;//当前显示储能变流器VBC
			case 0x0025:value =PCS_Info[id].PCS3x.Rmeasure.VCA;break;//当前显示储能变流器VCA
			case 0x0026:value =PCS_Info[id].PCS3x.Rmeasure.Grid_Frequency;break;//当前显示储能变流器电网频率
			case 0x0027:value =PCS_Info[id].PCS3x.Rmeasure.IA;break;//当前显示储能变流器IA
			case 0x0028:value =PCS_Info[id].PCS3x.Rmeasure.IB;break;//当前显示储能变流器IB
			case 0x0029:value =PCS_Info[id].PCS3x.Rmeasure.IC;break;//当前显示储能变流器IC
			case 0x002A:value =PCS_Info[id].PCS3x.Rmeasure.Active_Power;break;//当前显示储能变流器有功功率
			case 0x002B:value =PCS_Info[id].PCS3x.Rmeasure.Reactive_Power;break;//当前显示储能变流器无功功率
			case 0x002C:value =PCS_Info[id].PCS3x.Rmeasure.Power_Factor;break;//当前显示储能变流器功率因数
			case 0x002D:value = PCS_Info[id].PCS3x.Rmeasure.Total_Charge_Energe;break;//当前显示储能变流器累计充电
			case 0x002E:value = PCS_Info[id].PCS3x.Rmeasure.Total_Discharge_Energe;break;//当前显示储能变流器累计放电
			case 0x002F:value = PCS_Info[id].PCS3x.RCommunication.Run_Status;break;//当前显示储能变流器工作状态
			case 0x0030:value = PCS_Info[id].PCS3x.RCommunication.Fault_Status1;break;//当前显示储能变流器故障状态1
			case 0x0031:value = PCS_Info[id].PCS3x.RCommunication.Fault_Status2;break;//当前显示储能变流器故障状态2
			default:value = 0; break;
		}
	}
	else if(addr == 0x0040)
	{
		value = Cur_PVS_Num;
	}
	else if(addr > 0x0040 && addr <= 0x0047)		//光伏汇流箱信息
	{
		switch(addr)
		{  	
			case 0x0041:value = PVS_Info[id].DC_Vol;break;//
			case 0x0042:value = PVS_Info[id].Total_I;break;//
			case 0x0043:value = PVS_Info[id].Total_P_DC;break;//
			case 0x0044:value = PVS_Info[id].Output_Pt_Day;break;//
			case 0x0045:value = PVS_Info[id].Output_Pt_Total;break;//
			case 0x0046:value = PVS_Info[id].Room_T;break;//
			case 0x0047:value = PVS_Info[id].Work_Status;break;//
			default:value = 0; break;
		}
	}
	else if(addr == 0x0050)
	{
		value = Cur_BMS_Num;
	}
	else if(addr > 0x0050 && addr <= 0x006D)		//BMS信息
	{
		switch(addr)
		{
			case 0x0051:value = BMS_Info[id].Sys_Voltage;break;//
			case 0x0052:value = BMS_Info[id].Sys_Current;break;//
			case 0x0053:value = BMS_Info[id].Sys_SOC;break;//
			case 0x0054:value = BMS_Info[id].Sys_SOH;break;//
			case 0x0055:value = BMS_Info[id].Single_V_Min;break;//
			case 0x0056:value = BMS_Info[id].Single_V_Max;break;//
			case 0x0057:value = BMS_Info[id].Single_T_Min;break;//
			case 0x0058:value = BMS_Info[id].Single_T_Max;break;//
			case 0x0059:value = 0;break;//
			case 0x005A:value = 0;break;//
			case 0x005B:value = 0;break;//
			case 0x005C:value = 0;break;//
			case 0x005D:value = 0;break;//
			case 0x005E:value = 0;break;//
			case 0x005F:value = 0;break;//
			case 0x0060:value = 0;break;//
			case 0x0061:value = 0;break;//
			case 0x0062:value = 0;break;//
			case 0x0063:value = 0;break;//
			case 0x0064:value = 0;break;//
			case 0x0065:value = 0;break;//
			case 0x0066:value = 0;break;//
			case 0x0067:value = 0;break;//
			case 0x0068:value = 0;break;//
			case 0x0069:value = 0;break;//
			case 0x006A:value = 0;break;//
			case 0x006B:value = 0;break;//
			case 0x006C:value = 0;break;//
			case 0x006D:value = 0;break;//
			default:value = 0; break;
		}
	}
	else if(addr == 0x0070)
	{
		value = Cur_DCDC_Num;
	}
	else if(addr >= 0x0071 && addr <= 0x00BC)		//DCDC信息
	{
		switch(addr)
		{
			case 0x0071:value = (uint32_t)DCDC_Info[id].Module_1.Module_Array_V;break;//阵列电压1
			case 0x0072:value = (uint32_t)DCDC_Info[id].Module_1.Module_Array_I;break;//阵列电流1
			case 0x0073:value = (uint32_t)DCDC_Info[id].Module_1.Module_Bat_V;break;//电池电压1
			case 0x0074:value = (uint32_t)DCDC_Info[id].Module_1.Module_Charge_I;break;//充电电流1
			case 0x0075:value = DCDC_Info[id].Module_1.Module_Charge_P;break;//充电功率1
			case 0x0076:value = (uint32_t)DCDC_Info[id].Module_1.Module_In_Temp;break;//机内温度1
			case 0x0077:value = (uint32_t)DCDC_Info[id].Module_1.Module_Bat_Temp;break;//电池温度1
			case 0x0078:
				if(DCDC_Com_Err[id])
					value = (uint32_t)6;
				else
					value = (uint32_t)DCDC_Info[id].Module_1.Module_Dev_Status;
				break;//设备状态1
			case 0x0079:value = (uint32_t)DCDC_Info[id].Module_1.Module_Dev_Fault_Status;break;//故障状态1
			case 0x007A:value = (uint32_t)DCDC_Info[id].Module_1.Module_Output_E_Day;break;//日发电量
			case 0x007B:value = DCDC_Info[id].Module_1.Module_Output_E_Mon;break;//月发电量
			case 0x007C:value = DCDC_Info[id].Module_1.Module_Output_E_Total;break;//发电总量
			case 0x007D:value = DCDC_Info[id].Module_1.Module_CO2_Reduced;break;//二氧化碳减排
			case 0x007E:value = (uint32_t)DCDC_Info[id].Module_1.Module_Run_Min_Day;break;//日运行分钟
			case 0x007F:value = (uint32_t)DCDC_Info[id].Module_1.Module_Run_Hour_Mon;break;//月运行时数
			case 0x0080:value = DCDC_Info[id].Module_1.Module_Run_Hour_Total;break;//总运行时数
			
			case 0x0085:value = (uint32_t)DCDC_Info[id].Module_2.Module_Array_V;break;//阵列电压2
			case 0x0086:value = (uint32_t)DCDC_Info[id].Module_2.Module_Array_I;break;//阵列电流2
			case 0x0087:value = (uint32_t)DCDC_Info[id].Module_2.Module_Bat_V;break;//电池电压2
			case 0x0088:value = (uint32_t)DCDC_Info[id].Module_2.Module_Charge_I;break;//充电电流2
			case 0x0089:value = DCDC_Info[id].Module_2.Module_Charge_P;break;//充电功率2
			case 0x008A:value = (uint32_t)DCDC_Info[id].Module_2.Module_In_Temp;break;//机内温度2
			case 0x008B:value = (uint32_t)DCDC_Info[id].Module_2.Module_Bat_Temp;break;//电池温度2
			case 0x008C:
				if(DCDC_Com_Err[id])
					value = (uint32_t)6;
				else
					value = (uint32_t)DCDC_Info[id].Module_2.Module_Dev_Status;
				break;//设备状态2
			case 0x008D:value = (uint32_t)DCDC_Info[id].Module_2.Module_Dev_Fault_Status;break;//故障状态2
			case 0x008E:value = (uint32_t)DCDC_Info[id].Module_2.Module_Output_E_Day;break;//日发电量
			case 0x008F:value = DCDC_Info[id].Module_2.Module_Output_E_Mon;break;//月发电量
			case 0x0090:value = DCDC_Info[id].Module_2.Module_Output_E_Total;break;//发电总量
			case 0x0091:value = DCDC_Info[id].Module_2.Module_CO2_Reduced;break;//二氧化碳减排
			case 0x0092:value = (uint32_t)DCDC_Info[id].Module_2.Module_Run_Min_Day;break;//日运行分钟
			case 0x0093:value = (uint32_t)DCDC_Info[id].Module_2.Module_Run_Hour_Mon;break;//月运行时数
			case 0x0094:value = DCDC_Info[id].Module_2.Module_Run_Hour_Total;break;//总运行时数

			case 0x0099:value = (uint32_t)DCDC_Info[id].Module_3.Module_Array_V;break;//阵列电压3
			case 0x009A:value = (uint32_t)DCDC_Info[id].Module_3.Module_Array_I;break;//阵列电流3
			case 0x009B:value = (uint32_t)DCDC_Info[id].Module_3.Module_Bat_V;break;//电池电压3
			case 0x009C:value = (uint32_t)DCDC_Info[id].Module_3.Module_Charge_I;break;//充电电流3
			case 0x009D:value = DCDC_Info[id].Module_3.Module_Charge_P;break;//充电功率3
			case 0x009E:value = (uint32_t)DCDC_Info[id].Module_3.Module_In_Temp;break;//机内温度3
			case 0x009F:value = (uint32_t)DCDC_Info[id].Module_3.Module_Bat_Temp;break;//电池温度3
			case 0x00A0:
				if(DCDC_Com_Err[id])
					value = (uint32_t)6;
				else
					value = (uint32_t)DCDC_Info[id].Module_3.Module_Dev_Status;
				break;//设备状态3
			case 0x00A1:value = (uint32_t)DCDC_Info[id].Module_3.Module_Dev_Fault_Status;break;//故障状态3
			case 0x00A2:value = (uint32_t)DCDC_Info[id].Module_3.Module_Output_E_Day;break;//日发电量
			case 0x00A3:value = DCDC_Info[id].Module_3.Module_Output_E_Mon;break;//月发电量
			case 0x00A4:value = DCDC_Info[id].Module_3.Module_Output_E_Total;break;//发电总量
			case 0x00A5:value = DCDC_Info[id].Module_3.Module_CO2_Reduced;break;//二氧化碳减排
			case 0x00A6:value = (uint32_t)DCDC_Info[id].Module_3.Module_Run_Min_Day;break;//日运行分钟
			case 0x00A7:value = (uint32_t)DCDC_Info[id].Module_3.Module_Run_Hour_Mon;break;//月运行时数
			case 0x00A8:value = DCDC_Info[id].Module_3.Module_Run_Hour_Total;break;//总运行时数

			case 0x00AD:value = (uint32_t)DCDC_Info[id].Module_4.Module_Array_V;break;//阵列电压4
			case 0x00AE:value = (uint32_t)DCDC_Info[id].Module_4.Module_Array_I;break;//阵列电流4
			case 0x00AF:value = (uint32_t)DCDC_Info[id].Module_4.Module_Bat_V;break;//电池电压4
			case 0x00B0:value = (uint32_t)DCDC_Info[id].Module_4.Module_Charge_I;break;//充电电流4
			case 0x00B1:value = DCDC_Info[id].Module_4.Module_Charge_P;break;//充电功率4
			case 0x00B2:value = (uint32_t)DCDC_Info[id].Module_4.Module_In_Temp;break;//机内温度4
			case 0x00B3:value = (uint32_t)DCDC_Info[id].Module_4.Module_Bat_Temp;break;//电池温度4
			case 0x00B4:
				if(DCDC_Com_Err[id])
					value = (uint32_t)6;
				else
					value = (uint32_t)DCDC_Info[id].Module_4.Module_Dev_Status;
				break;//设备状态4
			case 0x00B5:value = (uint32_t)DCDC_Info[id].Module_4.Module_Dev_Fault_Status;break;//故障状态4
			case 0x00B6:value = (uint32_t)DCDC_Info[id].Module_4.Module_Output_E_Day;break;//日发电量
			case 0x00B7:value = DCDC_Info[id].Module_4.Module_Output_E_Mon;break;//月发电量
			case 0x00B8:value = DCDC_Info[id].Module_4.Module_Output_E_Total;break;//发电总量
			case 0x00B9:value = DCDC_Info[id].Module_4.Module_CO2_Reduced;break;//二氧化碳减排
			case 0x00BA:value = (uint32_t)DCDC_Info[id].Module_4.Module_Run_Min_Day;break;//日运行分钟
			case 0x00BB:value = (uint32_t)DCDC_Info[id].Module_4.Module_Run_Hour_Mon;break;//月运行时数
			case 0x00BC:value = DCDC_Info[id].Module_4.Module_Run_Hour_Total;break;//总运行时数
			default:value = 0; break;
		}
	}
	else if(addr == 0x130)
	{
		value = Cur_PV_Num;
	}
	else if(addr >= 0x0131 && addr <= 0x013D)		//光伏逆变器信息
	{
		switch(addr)
		{	
			case 0x0131:value = PV_Info[id].PV3x.RunParameter.DC_Voltage1;break;//当前显示光伏逆变器直流电压1
			case 0x0132:value = PV_Info[id].PV3x.RunParameter.DC_Current1;break;//当前显示光伏逆变器直流电流1
			case 0x0133:value = PV_Info[id].PV3x.RunParameter.DC_Voltage2;break;//当前显示光伏逆变器直流电压2
			case 0x0134:value = PV_Info[id].PV3x.RunParameter.DC_Current2;break;//当前显示光伏逆变器直流电流2
			case 0x0135:value = PV_Info[id].PV3x.RunParameter.VA;break;//当前显示光伏逆变器电网电压VA
			case 0x0136:value = PV_Info[id].PV3x.RunParameter.VB;break;//当前显示光伏逆变器电网电压VB
			case 0x0137:value = PV_Info[id].PV3x.RunParameter.VC;break;//当前显示光伏逆变器电网电压VC
			case 0x0138:value = PV_Info[id].PV3x.RunParameter.Frequency;break;//当前显示光伏逆变器电网频率
			case 0x0139:value = PV_Info[id].PV3x.RunParameter.Total_Active_Power;break;//当前显示光伏逆变器有功功率
			case 0x013A:value = PV_Info[id].PV3x.RunParameter.Reactive_Power;break;//当前显示光伏逆变器无功功率
			case 0x013B:value = PV_Info[id].PV3x.RunParameter.Power_Factor;break;//当前显示光伏逆变器功率因数
			case 0x013C:value = PV_Info[id].PV3x.RunParameter.Total_Generation;break;//当前显示光伏逆变器累计发电
			case 0x013D:value = PV_Info[id].PV3x.RunParameter.Inverter_Status;break;//当前显示光伏逆变器工作状态
			case 0x013E:value = PV_Info[id].PV4x.ParaSet.Power_ONOFF;break;//当前显示光伏逆变器开关机状态
			case 0x013F:value = PV_Info[id].PV4x.ParaSet.PowerLimit_Switch;break;//当前显示光伏逆变器限功率开关状态
			case 0x0140:value = PV_Info[id].PV4x.ParaSet.PowerLimit_Set;break;//当前显示光伏逆变器限功率值
			default:value = 0; break;
		}
	}
	else if(addr >= 0x014F && addr <= 0x03FF)
	{
		switch(addr)
		{
			case 0x014F:value = (uint16_t)(FAULT?6:(EMGSTOP?9:Run_Status(EMS_Info.EMS3x.EMS_Controller_Info.RCommunication.Total_Status)));break;	//系统状态
			case 0x0150:value = (uint32_t)EMS_Run_Mode;break;											//运行模式  0-电网优先；1-微网优先
			case 0x0151:value = (uint32_t)EMS_Start_Type;break;											//启动类型  0-主动模式；1-被动模式
			case 0x0152:value = EMS_Info.EMS3x.EMS_Controller_Info.RCommunication.Fault_Word1;break;	//故障1
			case 0x0153:value = EMS_Info.EMS3x.EMS_Controller_Info.RCommunication.Fault_Word2;break;	//故障2
			case 0x0154:value = EMS_Info.EMS3x.EMS_Controller_Info.RCommunication.Alarm_Word;break;		//告警
			case 0x0155:value = 0;break;																//充电量补偿值
			case 0x0156:value = 0;break;																//放电量补偿值
			case 0x0157:value = System_Info.Net.ip[0];break;											//IP地址[0]
			case 0x0158:value = System_Info.Net.ip[1];break;											//IP地址[1]
			case 0x0159:value = System_Info.Net.ip[2];break;											//IP地址[2]
			case 0x015A:value = System_Info.Net.ip[3];break;											//IP地址[3]
			case 0x015B:value = System_Info.Net.submask[0];break;										//子网掩码[0]
			case 0x015C:value = System_Info.Net.submask[1];break;										//子网掩码[1]
			case 0x015D:value = System_Info.Net.submask[2];break;										//子网掩码[2]
			case 0x015E:value = System_Info.Net.submask[3];break;										//子网掩码[3]
			case 0x015F:value = System_Info.Net.gateway[0];break;										//网关[0]
			case 0x0160:value = System_Info.Net.gateway[1];break;										//网关[1]
			case 0x0161:value = System_Info.Net.gateway[2];break;										//网关[2]
			case 0x0162:value = System_Info.Net.gateway[3];break;										//网关[3]
			case 0x0163:value = System_Info.Baud_Rate;break;											//波特率
			case 0x0164:value = System_Info.Modbus_Address;break;										//上位机通讯地址
			case 0x0165:value = System_Info.Modbus_Port;break;											//modbus端口号
			case 0x0166:value = 0;break;//System_Info.IO_To_BMS_Mode;break;										//BMS通讯方式
			case 0x0167:value = 0;break;//System_Info.BMS_Fault_Contact_Enabled;break;							//BMS故障干接点
			case 0x0168:value = 0;break;//System_Info.BMS_Warning_Contact_Enabled;break;							//BMS告警干接点
			case 0x0169:value = System_Info.BMS_Address[0];break;										//BMS1通讯地址
			case 0x016A:value = System_Info.IEC104_Address;break;										//IEC104通讯地址
			case 0x016B:value = System_Info.IEC104_T1;break;											//IEC104超时时间T1
			case 0x016C:value = System_Info.IEC104_T3;break;											//IEC104超时时间T3
			case 0x016D:value = System_Info.IEC104_K;break;												//IEC104参数k
			case 0x016E:value = System_Info.IEC104_W;break;												//IEC104参数w
			case 0x016F:value = System_Info.BMS_Address[1];break;										//BMS2通讯地址
			
			case 0x0170:value = BcdToBin(showTime.tm_year)+2000;break;									//年
			case 0x0171:value = BcdToBin(showTime.tm_mon);break;										//月
			case 0x0172:value = BcdToBin(showTime.tm_day);break;										//日
			case 0x0173:value = BcdToBin(showTime.tm_hour);break;										//时
			case 0x0174:value = BcdToBin(showTime.tm_min);break;										//分
			
			case 0x0175:value = 0;break;//(int32_t)EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_I_Mode_I;break;
			case 0x0176:value = (uint32_t)EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_V_Mode_V;break;
			case 0x0177:value = (uint32_t)EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_V_Mode_I;break;
			case 0x0178:value = 0;break;//(int32_t)EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_P_DC_Mode_P;break;
			case 0x0179:value = (int32_t)EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_P_AC_Mode_P;break;
			
			case 0x017A:value = 0;break;		//恒流放电电流(保留)
			case 0x017B:value = 0;break;		//限压放电电压(保留)
			case 0x017C:value = 0;break;		//限压放电限制电流(保留)
			
			case 0x0180:value = 0;break;																//独立逆变电压
			case 0x0181:value = 0;break;																//独立逆变频率
			case 0x0182:value = (System_Info.VSG_func_enable==1)?2:0;break;;							//0: 并网模式， 2：VSG模式  VSG_Para.VSG_run_mode_set
			case 0x0184:value = EMS_Info.EMS4x.AGC_Info.SysParameter.Qvar_Adj_Mode;break;				
			case 0x0185:value = EMS_Info.EMS4x.AGC_Info.SysParameter.Power_Factor;break;				//功率因数
			case 0x0186:value = EMS_Info.EMS4x.AGC_Info.SysParameter.Qvar_Power_Ratio;break;			//无功比例，只读
			case 0x0187:value = OnGrid_Run_Mode;break;													//并网模式设置
			case 0x0188:value = EMS_Start_Type;break;													//启动类型：0:主动1:被动									
			//case 0x0189:value = 0;break;																//起停控制, 只写
				
			case 0x018C:value = VSG_Para.VSG_u0_set;break;												//VSG输出电压给定值
			case 0x018D:value = VSG_Para.VSG_w0_set;break;												//VSG输出频率给定值
			case 0x018E:value = VSG_Para.VSG_P_down_control_ratio;break;								//有功下垂控制系数
			case 0x018F:value = VSG_Para.VSG_Q_down_control_ratio;break;								//无功下垂控制系数
			case 0x0190:value = VSG_Para.VSG_Pref_set;break;											//二次调频给定值
			case 0x0191:value = VSG_Para.VSG_Qref_set;break;											//无功下发给定值
			
			case 0x0206:value = SuperPwd;break;															//是否是超级密码登录
			case 0x0282:value = userFlag;break;															//当前用户标识

			case 0x0301:value = Webserver_Language;break;												//页面语言
			
			case 0x0310:value = DIN(GRID_CONTACTOR);break;												//电网侧接触器状态
			case 0x0311:value = DIN(MGRID_CONTACTOR);break;												//微网侧接触器状态
			case 0x0312:value = Grid_Pic_Direction;break;												//电网图片滚动方向
			case 0x0313:value = MGrid_Pic_Direction;break;												//微网图片流动方向	
			case 0x0314:value = PV_Pic_Direction;break;		    										//光伏逆变器图片滚动方向
			case 0x0315:value = Load_Pic_Direction;break;												//负载图片滚动方向
			case 0x0316:value = (uint32_t)(!DC_BUS_SYS);break;		    								//是否交流母线系统？
			
			case 0x0317:value = (uint32_t)((VSG_Info.Grid_voltage_Vab+VSG_Info.Grid_voltage_Vbc)/2);break;//电网电压
			case 0x0318:value = (uint32_t)EMS_Info.EMS3x.AGC_Info.RMeasure.Load_Voltage;break;			//负载电压
			case 0x0319:value = EMS_Info.EMS3x.AGC_Info.RMeasure.Load_Active_Power;break;				//负载功率
			case 0x031A:value = EMS_Info.EMS3x.SOC_Info.RMeasure.PCS_AC_Voltage_Max;break;				//PCS交流电压
			case 0x031B:value = EMS_Info.EMS3x.AGC_Info.RMeasure.PCS_Active_Power;break;				//PCS功率
			case 0x031C:value = System_Run_Info.PV_DC_Voltage;break;									//PV直流电压
			case 0x031D:value = EMS_Info.EMS3x.AGC_Info.RMeasure.PV_Active_Power;break;					//PV功率
			case 0x031E:value = BMS_Info[0].Sys_SOC;break;												//BMS soc
			case 0x031F:value = BMS_Info[0].Sys_SOH;break;												//BMS 健康度
			case 0x0320:value = System_Run_Info.PCS_DC_Voltage;break;									//PCS直流电压
			
			case 0x0380:value = System_Info.PCS_Protocol_Type;break;									//协议选择
			case 0x0381:value = Bus_Type;break;															//总线类型
			case 0x0382:value = Grid_Connect_Type;break;												//是否并网
			case 0x0383:value = DC_Bus_Charge_Permit;break;												//直流母线充电使能
			case 0x0384:value = System_Power_Set;break;													//系统功率
			case 0x0385:value = PCS_Power_Type;break;													//PCS机器类型
			case 0x0386:value = DCDC_Type;break;														//DCDC类型
			case 0x0387:value = EMS_Run_Mode;break;														//优先级
			
			case 0x0388:value = System_Info.VSG_func_enable;break;										//SG模式使能开关
			case 0x0389:value = System_Info.Time_Slot_Enable;break;                                     //是否分时段控制
			
			case 0x0390:value = webPageShow.pcs;break;													//web是否显示pcs界面
			case 0x0391:value = webPageShow.pv;break;													//web是否显示pv界面
			case 0x0392:value = webPageShow.dcdc;break;													//web是否显示dcdc界面
			case 0x0393:value = webPageShow.pvs;break;													//web是否显示pvs界面
			case 0x0394:value = webPageShow.bms;break;													//web是否显示bms界面
			case 0x0395:value = webPageShow.ammeter;break;												//web是否显示电表界面
			case 0x0396:value = webPageShow.realtimeMonitor;break;										//web是否显示实时监控界面
			default: value=0;break;
		}
	}
	else if(addr >= 0x0400 && addr <= 0x0423)
	{
		switch(addr)
		{
			case 0x0401:value = (int16_t)EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_V_Mode_I_Min;break;
			case 0x0402:value = (int16_t)EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_V_Mode_I_Max;;break;
			case 0x0403:value = (uint32_t)EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_V_Mode_V_Min;break;
			case 0x0404:value = (uint32_t)EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_V_Mode_V_Max;;break;
			case 0x0405:value = (uint32_t)EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_V_Mode_I_Min;break;
			case 0x0406:value = (uint32_t)EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_V_Mode_I_Max;break;
			case 0x0407:value = (int16_t)EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_P_AC_Mode_P_Min;break;  //恒功率模式功率下限 , DC/AC范围一样
			case 0x0408:value = (int16_t)EMS_Info.EMS4x.EMS_Controller_Info.EM.Const_P_AC_Mode_P_Max;break;  //恒功率模式功率上限
			case 0x0409:value = 0;break;		//保留，根据具体项目设定
			case 0x040A:value = 0;break;		//保留，根据具体项目设定
			case 0x040B:value = 0;break;		//保留，根据具体项目设定
			case 0x040C:value = 0;break;		//保留，根据具体项目设定
			case 0x040D:value = 0;break;		//保留，根据具体项目设定
			case 0x040E:value = 0;break;		//保留，根据具体项目设定
			case 0x040F:value = 0;break;		//保留，根据具体项目设定
			case 0x0410:value = 3800;break;		//独立逆变电压下限，根据具体项目设定
			case 0x0411:value = 4100;break;		//独立逆变电压上限，根据具体项目设定
			case 0x0412:value = 4700;break;		//独立逆变频率下限，根据具体项目设定
			case 0x0413:value = 5200;break;		//独立逆变频率上限，根据具体项目设定
			case 0x0414:value = (int16_t)(-P_Range[PCS_Power_Type].Power_Factor.Min);break;		//功率因数下限
			case 0x0415:value = (int16_t)(-P_Range[PCS_Power_Type].Power_Factor.Max);break;		//功率因数上限
			case 0x0416:value = (int16_t)(-1*1000);break;			//无功比例下限
			case 0x0417:value = (int16_t)(1000);break;			//无功比例上限
			case 0x0418:value = VSG_Range[VSG_U0].Min;break;
			case 0x0419:value = VSG_Range[VSG_U0].Max;break;
			case 0x041A:value = VSG_Range[VSG_W0].Min;break;
			case 0x041B:value = VSG_Range[VSG_W0].Max;break;
			case 0x041C:value = VSG_Range[VSG_P_DOWN_CONTROL_RATIO].Min;break;
			case 0x041D:value = VSG_Range[VSG_P_DOWN_CONTROL_RATIO].Max;break;	
			case 0x041E:value = VSG_Range[VSG_Q_DOWN_CONTROL_RATIO].Min;break;
			case 0x041F:value = VSG_Range[VSG_Q_DOWN_CONTROL_RATIO].Max;break;
			case 0x0420:value = VSG_Range[VSG_PREF].Min;break;
			case 0x0421:value = VSG_Range[VSG_PREF].Max;break;
			case 0x0422:value = VSG_Range[VSG_QREF].Min;break;
			case 0x0423:value = VSG_Range[VSG_QREF].Max;break;			
			default: value=0;break;
		}
	}
	else if(addr == 0x04FF)
	{
		value=0;
	}
	else if(addr >= 0x0500 && addr <= 0x05FF)
	{
		uint8_t index = 0;
		index = (addr-0x0500)/16;
		uint32_t Addr_r = 0x0500+((addr-0x0500))%16;
		if(index>TIMESLOT_NUM-1) return 0;	
		switch(Addr_r)
		{
			case 0x0500: value = time_slot[index].st_year;break;
			case 0x0501: value = time_slot[index].st_mon;break;
			case 0x0502: value = time_slot[index].st_day;break;
			case 0x0503: value = time_slot[index].st_hour;break;
			case 0x0504: value = time_slot[index].st_min;break;
			case 0x0505: value = time_slot[index].end_year;break;
			case 0x0506: value = time_slot[index].end_mon;break;
			case 0x0507: value = time_slot[index].end_day;break;
			case 0x0508: value = time_slot[index].end_hour;break;
			case 0x0509: value = time_slot[index].end_min;break;
			case 0x050A: value = time_slot[index].running_mode;break;
			case 0x050B: value = time_slot[index].ctrl_mode;break;
			case 0x050C: value = time_slot[index].power;break;
			default: value=0;break;
		}
	}	
	
    return value;	
}
uint32_t get_realtimedata_by_id(uint32_t addr, uint8_t id)
{
    uint32_t value = 0;
	
	if(addr==0x0290 || addr==0x0291 || addr==0x0292)
	switch(id)
	{
		case 0: value = 400;break;
		case 1: value = 80;break;
		case 2: value = 670;break;
		case 3: value = 110;break;
		case 4: value = 200;break;
		case 5: value = 300;break;
		case 6: value = 50;break;
		default: value=0;break;
	}
    return value;
}
void webserver_do_save_int(void)								//异步保存参数值(数值型)
{
	Touch_Write_Time[0]=showTime.tm_year;
	Touch_Write_Time[1]=showTime.tm_mon;
	Touch_Write_Time[2]=showTime.tm_day;
	Touch_Write_Time[3]=showTime.tm_hour;
	Touch_Write_Time[4]=showTime.tm_min;
	Touch_Write_Time[5]=showTime.tm_sec;
	
    for(int i=0;i<PARAMETER_NUM;i++)
    {
        if(Param_flag[i]!=0)
        {
            do_save_data_int(Param_flag[i],Param_value[i]);
            Param_flag[i]=0;
        }
    }
	if(Touch_Write_Time_Flag==true)
	{
		Touch_Write_Time_Flag=false;
		(void)drv_write(gt_glp.frtc,Touch_Write_Time,6);//设置时间函数
		get_sys_time();
		for(uint8_t i=0;i<EMS_Info.EMS4x.AGC_Info.SysParameter.Total_PCS_Number;i++)
		{
			Send_Data_To_PCS_0x10_01[i]=true;
		}
		for(uint8_t i=0;i<EMS_Info.EMS4x.AGC_Info.SysParameter.Total_PV_Number;i++)
		{
			Send_Data_To_PV_0x10_01[i]=true;
		}
		delay10s=true;
		Clear_Data = true;								//判断是否是新的一天，是否要清除前一天的数据
	}
}
void s_handler(int id,char* data)								//处理初始化参数值
{
	char *ptemp=NULL;//切割出的内容
	char delim[] = "?=&+";//切割字符串
	uint8_t reg[3],i=0;
    switch(id)
    {
        case 0: //登录
        case 1: //框架
		case 20://7777框架
		case 21://7777菜单
            sprintf(s_000,
                "HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n"
                "{"
					"ID_0x0202:'%s',"  //设备名称
                    "ID_0x0301:%d"     //页面语言
			    "}",
                    Device_Info[DEVICE_NAME],
                    get_param_by_id(0x0301,0x0)
			);
            s_Rsc[0].size = strlen(s_000);
        break;
		case 2://概要信息
            sprintf(s_000,
                "HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n"
                "{"
                    "ID_0x0301:%d,"   //页面语言
                    "ID_0x014F:%d,"   //EMS工作状态
                    "ID_0x0182:%d,"   //工作模式	0-并网模式，1-VSG模式
                    "ID_0x0150:%d,"   //启动模式    0-电网优先；1-微网优先
                    "ID_0x0151:%d,"   //启动类型    0-主动模式；1-被动模式
					"ID_0x0016:%d,"	  //微网电压
					"ID_0x0017:%d,"	  //微网频率
					"ID_0x0004:%d,"	  //电网状态
                    "ID_0x0005:%d,"   //负载总有功功率
					"ID_0x0008:%d,"   //光伏总有功功率
					"ID_0x000B:%d,"   //负载功率
					"ID_0x0310:%d,"	  //电网侧接触器状态
					"ID_0x0311:%d,"	  //微网侧接触器状态
					"ID_0x0312:%d,"   //电网图片滚动方向
					"ID_0x0313:%d,"   //储能变流器图片滚动方向
					"ID_0x0314:%d,"   //光伏逆变器图片滚动方向
					"ID_0x0315:%d,"   //负载供电滚动方向
					"ID_0x0316:%d,"    //是否交流母线系统?
					"ID_0x0317:%d,"	  //电网电压
					"ID_0x0318:%d,"   //负载电压
					"ID_0x0319:%d,"	  //负载有功功率
					"ID_0x031A:%d,"   //储能交流电压
					"ID_0x031B:%d,"   //储能有功功率					
					"ID_0x031C:%d,"   //光伏直流电压
					"ID_0x031D:%d,"   //光伏有功功率
					"ID_0x031E:%d,"	  //SOC
					"ID_0x031F:%d,"   //SOH
					"ID_0x0320:%d,"   //储能直流侧电压
					"ID_0x0381:%d"    //母线类型
			    "}",
                    get_param_by_id(0x0301,0),
                    get_param_by_id(0x014F,0),
                    get_param_by_id(0x0182,0),
                    get_param_by_id(0x0150,0),
                    get_param_by_id(0x0151,0),
                    get_param_by_id(0x0016,0),
                    get_param_by_id(0x0017,0),
					get_param_by_id(0x0004,0),
					get_param_by_id(0x0005,0),
					get_param_by_id(0x0008,0),
					get_param_by_id(0x000B,0),	
					get_param_by_id(0x0310,0),
					get_param_by_id(0x0311,0),
					get_param_by_id(0x0312,0),
					get_param_by_id(0x0313,0),
					get_param_by_id(0x0314,0),
					get_param_by_id(0x0315,0),
					get_param_by_id(0x0316,0),	
					get_param_by_id(0x0317,0),
					get_param_by_id(0x0318,0),
					get_param_by_id(0x0319,0),
					get_param_by_id(0x031A,0),
					get_param_by_id(0x031B,0),
					get_param_by_id(0x031C,0),
					get_param_by_id(0x031D,0),
					get_param_by_id(0x031E,0),
					get_param_by_id(0x031F,0),
					get_param_by_id(0x0320,0),
					get_param_by_id(0x0381,0)
			);
            s_Rsc[0].size = strlen(s_000);
		break;
        case 3: //PCS信息
            sprintf(s_000,
                "HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n"
                "{"
                    "ID_0x0301:%d,"   //页面语言
                    "ID_0x0020:%d,"   //直流电压
                    "ID_0x0021:%d,"   //直流电流
                    "ID_0x0022:%d,"   //直流功率
                    "ID_0x002A:%d,"   //有功功率
                    "ID_0x002B:%d,"   //无功功率
                    "ID_0x002C:%d,"   //功率因数
                    "ID_0x0023:%d,"   //A相电压
                    "ID_0x0027:%d,"   //A相电流
                    "ID_0x0024:%d,"   //B相电压
                    "ID_0x0028:%d,"   //B相电流
                    "ID_0x0025:%d,"   //C相电压
                    "ID_0x0029:%d,"   //C相电流
                    "ID_0x0026:%d,"   //电网频率
                    "ID_0x002D:%d,"   //总充电量
                    "ID_0x002E:%d,"   //总放电量
					"ID_0x002F:%d,"   //设备状态	
                    "ID_0x0030:%d,"   //故障状态1
                    "ID_0x0031:%d,"   //故障状态2
					"ID_0x001F:%d,"	  //当前PCS编号
					"ID_0x001A:%d"	  //PCS总数
			    "}",
                    get_param_by_id(0x0301,Cur_PCS_Num-1),
                    get_param_by_id(0x0020,Cur_PCS_Num-1),
                    get_param_by_id(0x0021,Cur_PCS_Num-1),
                    get_param_by_id(0x0022,Cur_PCS_Num-1),
                    get_param_by_id(0x002A,Cur_PCS_Num-1),
                    get_param_by_id(0x002B,Cur_PCS_Num-1),
                    get_param_by_id(0x002C,Cur_PCS_Num-1),
                    get_param_by_id(0x0023,Cur_PCS_Num-1),
                    get_param_by_id(0x0027,Cur_PCS_Num-1),
                    get_param_by_id(0x0024,Cur_PCS_Num-1),
                    get_param_by_id(0x0028,Cur_PCS_Num-1),
                    get_param_by_id(0x0025,Cur_PCS_Num-1),
                    get_param_by_id(0x0029,Cur_PCS_Num-1),
                    get_param_by_id(0x0026,Cur_PCS_Num-1),
                    get_param_by_id(0x002D,Cur_PCS_Num-1),
                    get_param_by_id(0x002E,Cur_PCS_Num-1),
                    get_param_by_id(0x002F,Cur_PCS_Num-1),
                    get_param_by_id(0x0030,Cur_PCS_Num-1),
                    get_param_by_id(0x0031,Cur_PCS_Num-1),
                    get_param_by_id(0x001F,Cur_PCS_Num-1),
                    get_param_by_id(0x001A,Cur_PCS_Num-1)
			);
            s_Rsc[0].size = strlen(s_000);
        break;
        case 4: //系统参数
            sprintf(s_000,
                "HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n"
                "{"
                    "ID_0x0301:%d,"   //页面语言
                    "ID_0x0170:%d,"   //系统时钟(年)
                    "ID_0x0171:%d,"   //系统时钟(月)
                    "ID_0x0172:%d,"   //系统时钟(日)
                    "ID_0x0173:%d,"   //系统时钟(时)
                    "ID_0x0174:%d,"   //系统时钟(分)
                    "ID_0x0282:%d"    //用户名称
			    "}",
                    get_param_by_id(0x0301,0),
                    get_param_by_id(0x0170,0),
                    get_param_by_id(0x0171,0),
                    get_param_by_id(0x0172,0),
                    get_param_by_id(0x0173,0),
                    get_param_by_id(0x0174,0),
                    get_param_by_id(0x0282,0)
			);
            s_Rsc[0].size = strlen(s_000);
        break;
        case 5: //运行参数
            sprintf(s_000,
                "HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n"
                "{"
                    "ID_0x0301:%d,"   //页面语言
                    "ID_0x0175:%d,"   //恒流充电电流
                    "ID_0x0176:%d,"   //恒压充电限流值
                    "ID_0x0177:%d,"   //恒压充电电压
                    "ID_0x0178:%d,"   //恒功率充电功率 DC
                    "ID_0x0179:%d,"   //恒功率充电功率 AC
                    "ID_0x0180:%d,"   //独立逆变电压
                    "ID_0x0181:%d,"   //独立逆变频率
                    "ID_0x0182:%d,"   //工作模式
                    "ID_0x0184:%d,"   //无功调节选择开关
                    "ID_0x0185:%d,"   //功率因数
                    "ID_0x0186:%d,"   //无功比例
                    "ID_0x0187:%d,"   //并网模式设置
                    "ID_0x0188:%d,"   //离网主被动模式设置
                    "ID_0x0189:%d,"   //离网模式设置
					//"ID_0x018C:%d,"	  //VSG输出电压给定值
					//"ID_0x018D:%d,"   //VSG输出频率给定值
					"ID_0x018E:%d,"   //有功下垂控制系数
					"ID_0x018F:%d,"   //无功下垂控制系数
					"ID_0x0190:%d,"   //二次调频给定值
					"ID_0x0191:%d,"   //无功下发给定值
					"ID_0x0388:%d,"   //VSG使能
					"ID_0x0389:%d,"   //分时功能使能
                    //"ID_0x0400:%d,"   //恒流充电电流下限
                    //"ID_0x0401:%d,"   //恒流充电电流上限
                    //"ID_0x0402:%d,"   //恒压充电电压下限
                    //"ID_0x0403:%d,"   //恒压充电电压上限
                    //"ID_0x0404:%d,"   //恒压充电限流值下限
                    //"ID_0x0405:%d,"   //恒压充电限流值上限
                    //"ID_0x0406:%d,"   //恒功率充电功率下限
                    //"ID_0x0407:%d,"   //恒功率充电功率上限
                    //"ID_0x040E:%d,"   //恒功率放电功率下限
                    //"ID_0x040F:%d,"   //恒功率放电功率上限
                    //"ID_0x0410:%d,"   //独立逆变电压下限
                    //"ID_0x0411:%d,"   //独立逆变电压上限
                    //"ID_0x0412:%d,"   //独立逆变频率下限
                    //"ID_0x0413:%d,"   //独立逆变频率上限 
					//"ID_0x0418:%d,"	  //输出给定电压下限
					//"ID_0x0419:%d,"	  //输出给定电压上限
					//"ID_0x041A:%d,"   //输出给定频率下限
					//"ID_0x041B:%d,"   //输出给定频率上限
					"ID_0x041C:%d,"   //有功下垂控制系数下限
					"ID_0x041D:%d,"   //有功下垂控制系数上限
					"ID_0x0420:%d,"   //二次调频给定值下限
					"ID_0x0421:%d,"   //二次调频给定值上限
					"ID_0x0422:%d,"   //无功下发给定值下限
					"ID_0x0423:%d,"	  //无功下发给定值上限			
                    "ID_0x0282:%d,"    //用户名称
					
					"ID_0x0503:%d,"
					"ID_0x0504:%d,"
					"ID_0x0508:%d,"
					"ID_0x0509:%d,"
					"ID_0x050A:%d,"
					"ID_0x050B:%d,"
					"ID_0x050C:%d,"
					
					"ID_0x0513:%d,"
					"ID_0x0514:%d,"
					"ID_0x0518:%d,"
					"ID_0x0519:%d,"
					"ID_0x051A:%d,"
					"ID_0x051B:%d,"
					"ID_0x051C:%d,"
					
					"ID_0x0523:%d,"
					"ID_0x0524:%d,"
					"ID_0x0528:%d,"
					"ID_0x0529:%d,"
					"ID_0x052A:%d,"
					"ID_0x052B:%d,"
					"ID_0x052C:%d,"

					"ID_0x0533:%d,"
					"ID_0x0534:%d,"
					"ID_0x0538:%d,"
					"ID_0x0539:%d,"
					"ID_0x053A:%d,"
					"ID_0x053B:%d,"
					"ID_0x053C:%d,"
					
					"ID_0x0543:%d,"
					"ID_0x0544:%d,"
					"ID_0x0548:%d,"
					"ID_0x0549:%d,"
					"ID_0x054A:%d,"
					"ID_0x054B:%d,"
					"ID_0x054C:%d,"

					"ID_0x0553:%d,"
					"ID_0x0554:%d,"
					"ID_0x0558:%d,"
					"ID_0x0559:%d,"
					"ID_0x055A:%d,"
					"ID_0x055B:%d,"
					"ID_0x055C:%d,"
					
					"ID_0x0563:%d,"
					"ID_0x0564:%d,"
					"ID_0x0568:%d,"
					"ID_0x0569:%d,"
					"ID_0x056A:%d,"
					"ID_0x056B:%d,"
					"ID_0x056C:%d,"

					"ID_0x0573:%d,"
					"ID_0x0574:%d,"
					"ID_0x0578:%d,"
					"ID_0x0579:%d,"
					"ID_0x057A:%d,"
					"ID_0x057B:%d,"
					"ID_0x057C:%d,"
					
					"ID_0x0583:%d,"
					"ID_0x0584:%d,"
					"ID_0x0588:%d,"
					"ID_0x0589:%d,"
					"ID_0x058A:%d,"
					"ID_0x058B:%d,"
					"ID_0x058C:%d,"

					"ID_0x0593:%d,"
					"ID_0x0594:%d,"
					"ID_0x0598:%d,"
					"ID_0x0599:%d,"
					"ID_0x059A:%d,"
					"ID_0x059B:%d,"
					"ID_0x059C:%d,"
					
					"ID_0x05A3:%d,"
					"ID_0x05A4:%d,"
					"ID_0x05A8:%d,"
					"ID_0x05A9:%d,"
					"ID_0x05AA:%d,"
					"ID_0x05AB:%d,"
					"ID_0x05AC:%d,"

					"ID_0x05B3:%d,"
					"ID_0x05B4:%d,"
					"ID_0x05B8:%d,"
					"ID_0x05B9:%d,"
					"ID_0x05BA:%d,"
					"ID_0x05BB:%d,"
					"ID_0x05BC:%d"
			    "}",
                    get_param_by_id(0x0301,0),
                    get_param_by_id(0x0175,0),
                    get_param_by_id(0x0176,0),
                    get_param_by_id(0x0177,0),
                    get_param_by_id(0x0178,0),
                    get_param_by_id(0x0179,0),
                    get_param_by_id(0x0180,0),
                    get_param_by_id(0x0181,0),
                    get_param_by_id(0x0182,0),
                    get_param_by_id(0x0184,0),
                    get_param_by_id(0x0185,0),
                    get_param_by_id(0x0186,0),
                    get_param_by_id(0x0187,0),
                    get_param_by_id(0x0188,0),
                    get_param_by_id(0x0189,0),
                    //get_param_by_id(0x018C,0),
                    //get_param_by_id(0x018D,0),
                    get_param_by_id(0x018E,0),
                    get_param_by_id(0x018F,0),
                    get_param_by_id(0x0190,0),
                    get_param_by_id(0x0191,0),
					get_param_by_id(0x0388,0),
					get_param_by_id(0x0389,0),
                    //get_param_by_id(0x0400,0),
                    //get_param_by_id(0x0401,0),
                    //get_param_by_id(0x0402,0),
                    //get_param_by_id(0x0403,0),
                    //get_param_by_id(0x0404,0),
                    //get_param_by_id(0x0405,0),
                    //get_param_by_id(0x0406,0),
                    //get_param_by_id(0x0407,0),
                    //get_param_by_id(0x040E,0),
                    //get_param_by_id(0x040F,0),
                    //get_param_by_id(0x0410,0),
                    //get_param_by_id(0x0411,0),
                    //get_param_by_id(0x0412,0),
                    //get_param_by_id(0x0413,0),
                    //get_param_by_id(0x0418,0),
                    //get_param_by_id(0x0419,0),
                    //get_param_by_id(0x041A,0),
                    //get_param_by_id(0x041B,0),
                    get_param_by_id(0x041C,0),
                    get_param_by_id(0x041D,0),
                    get_param_by_id(0x0420,0),
                    get_param_by_id(0x0421,0),
                    get_param_by_id(0x0422,0),
                    get_param_by_id(0x0423,0),					
                    get_param_by_id(0x0282,0),
					//
					get_param_by_id(0x0503,0),
					get_param_by_id(0x0504,0),
					get_param_by_id(0x0508,0),
					get_param_by_id(0x0509,0),
					get_param_by_id(0x050A,0),
					get_param_by_id(0x050B,0),
					get_param_by_id(0x050C,0),
					//
					get_param_by_id(0x0513,0),
					get_param_by_id(0x0514,0),
					get_param_by_id(0x0518,0),
					get_param_by_id(0x0519,0),
					get_param_by_id(0x051A,0),
					get_param_by_id(0x051B,0),
					get_param_by_id(0x051C,0),
					//
					get_param_by_id(0x0523,0),
					get_param_by_id(0x0524,0),
					get_param_by_id(0x0528,0),
					get_param_by_id(0x0529,0),
					get_param_by_id(0x052A,0),
					get_param_by_id(0x052B,0),
					get_param_by_id(0x052C,0),
					//
					get_param_by_id(0x0533,0),
					get_param_by_id(0x0534,0),
					get_param_by_id(0x0538,0),
					get_param_by_id(0x0539,0),
					get_param_by_id(0x053A,0),
					get_param_by_id(0x053B,0),
					get_param_by_id(0x053C,0),
					//
					get_param_by_id(0x0543,0),
					get_param_by_id(0x0544,0),
					get_param_by_id(0x0548,0),
					get_param_by_id(0x0549,0),
					get_param_by_id(0x054A,0),
					get_param_by_id(0x054B,0),
					get_param_by_id(0x054C,0),
					//
					get_param_by_id(0x0553,0),
					get_param_by_id(0x0554,0),
					get_param_by_id(0x0558,0),
					get_param_by_id(0x0559,0),
					get_param_by_id(0x055A,0),
					get_param_by_id(0x055B,0),
					get_param_by_id(0x055C,0),
					//
					get_param_by_id(0x0563,0),
					get_param_by_id(0x0564,0),
					get_param_by_id(0x0568,0),
					get_param_by_id(0x0569,0),
					get_param_by_id(0x056A,0),
					get_param_by_id(0x056B,0),
					get_param_by_id(0x056C,0),
					//
					get_param_by_id(0x0573,0),
					get_param_by_id(0x0574,0),
					get_param_by_id(0x0578,0),
					get_param_by_id(0x0579,0),
					get_param_by_id(0x057A,0),
					get_param_by_id(0x057B,0),
					get_param_by_id(0x057C,0),
					//
					get_param_by_id(0x0583,0),
					get_param_by_id(0x0584,0),
					get_param_by_id(0x0588,0),
					get_param_by_id(0x0589,0),
					get_param_by_id(0x058A,0),
					get_param_by_id(0x058B,0),
					get_param_by_id(0x058C,0),
					//
					get_param_by_id(0x0593,0),
					get_param_by_id(0x0594,0),
					get_param_by_id(0x0598,0),
					get_param_by_id(0x0599,0),
					get_param_by_id(0x059A,0),
					get_param_by_id(0x059B,0),
					get_param_by_id(0x059C,0),
					//
					get_param_by_id(0x05A3,0),
					get_param_by_id(0x05A4,0),
					get_param_by_id(0x05A8,0),
					get_param_by_id(0x05A9,0),
					get_param_by_id(0x05AA,0),
					get_param_by_id(0x05AB,0),
					get_param_by_id(0x05AC,0),
					//
					get_param_by_id(0x05B3,0),
					get_param_by_id(0x05B4,0),
					get_param_by_id(0x05B8,0),
					get_param_by_id(0x05B9,0),
					get_param_by_id(0x05BA,0),
					get_param_by_id(0x05BB,0),
					get_param_by_id(0x05BC,0)				
			);
            s_Rsc[0].size = strlen(s_000);
        break;
        case 6: //通讯参数
            sprintf(s_000,
                "HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n"
                "{"
                    "ID_0x0301:%d,"   //页面语言
                    "ID_0x0157:%d,"   //IP地址[0]
                    "ID_0x0158:%d,"   //IP地址[1]
                    "ID_0x0159:%d,"   //IP地址[2]
                    "ID_0x015A:%d,"   //IP地址[3]
                    "ID_0x015B:%d,"   //子网掩码[0]
                    "ID_0x015C:%d,"   //子网掩码[1]
                    "ID_0x015D:%d,"   //子网掩码[2]
                    "ID_0x015E:%d,"   //子网掩码[3]
                    "ID_0x015F:%d,"   //网关[0]
                    "ID_0x0160:%d,"   //网关[1]
                    "ID_0x0161:%d,"   //网关[2]
                    "ID_0x0162:%d,"   //网关[3]
                    "ID_0x0163:%d,"   //波特率
                    "ID_0x0164:%d,"   //上位机通讯地址
                    "ID_0x0165:%d,"   //端口号
                    "ID_0x0166:%d,"   //BMS通讯方式
                    "ID_0x0167:%d,"   //BMS故障干接点
                    "ID_0x0168:%d,"   //BMS告警干接点
                    "ID_0x0169:%d,"   //BMS通讯地址
                    "ID_0x016A:%d,"   //IEC104通讯地址
                    "ID_0x016B:%d,"   //IEC104超时时间T1
                    "ID_0x016C:%d,"   //IEC104超时时间T3
                    "ID_0x016D:%d,"   //IEC104参数K
                    "ID_0x016E:%d,"   //IEC104参数W
                    "ID_0x0282:%d"    //用户名称
			    "}",
                    get_param_by_id(0x0301,0),
                    get_param_by_id(0x0157,0),
                    get_param_by_id(0x0158,0),
                    get_param_by_id(0x0159,0),
                    get_param_by_id(0x015A,0),
                    get_param_by_id(0x015B,0),
                    get_param_by_id(0x015C,0),
                    get_param_by_id(0x015D,0),
                    get_param_by_id(0x015E,0),
                    get_param_by_id(0x015F,0),
                    get_param_by_id(0x0160,0),
                    get_param_by_id(0x0161,0),
                    get_param_by_id(0x0162,0),
                    get_param_by_id(0x0163,0),
                    get_param_by_id(0x0164,0),
                    get_param_by_id(0x0165,0),
                    get_param_by_id(0x0166,0),
                    get_param_by_id(0x0167,0),
                    get_param_by_id(0x0168,0),
                    get_param_by_id(0x0169,0),
                    get_param_by_id(0x016A,0),
                    get_param_by_id(0x016B,0),
                    get_param_by_id(0x016C,0),
                    get_param_by_id(0x016D,0),
                    get_param_by_id(0x016E,0),
                    get_param_by_id(0x0282,0)
			);
            s_Rsc[0].size = strlen(s_000);
        break;
        case 10://系统信息
            sprintf(s_000,
				"HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n"
				"{"
                    "ID_0x0301:%d,"    //页面语言 
                    "ID_0x0203:'%s',"  //序列号
					"ID_0x0204:'%s',"  //设备名称
                    "ID_0x0205:'%s',"  //页面语言 
                    "ID_0x0206:%d"     //超级密码
				"}",
                    get_param_by_id(0x0301,0),
					Device_Info[FIRMWARE_VEB1],
					Device_Info[FIRMWARE_VEB2],
                    "",//Device_Info[FIRMWARE_VEB3],
                    get_param_by_id(0x0206,0)
			);
            s_Rsc[0].size = strlen(s_000);
        break;
         case 12://logo
		 sprintf(s_000,
			"HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n"
			"{"
				 "ID_0x0201:'%s',"  //序列号
				"ID_0x0202:'%s',"  //设备名称
				"ID_0x0301:%d,"    //页面语言 
				 "ID_0x0282:%d"     //用户名称
			"}",
			IAT_Info.Set_Info.SN_Number,
			Device_Info[DEVICE_NAME],
			get_param_by_id(0x0301,0),
			get_param_by_id(0x0282,0)
		);
		s_Rsc[0].size = strlen(s_000);
		break;
        case 7://运行记录
        case 8://事件记录
        case 9://故障记录
            sprintf(s_000,
                "HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n"
                "{"
					"ID_0x0301:%d" //页面语言 
			    "}",
                    get_param_by_id(0x0301,0)
			);
            s_Rsc[0].size = strlen(s_000);
        break;
        case 13://菜单
            sprintf(s_000,
                "HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n"
                "{"
					"ID_0x0301:%d," //页面语言 
					"ID_0x0390:%d," //PCS界面显示状态
					"ID_0x0391:%d," //PV界面显示状态
					"ID_0x0392:%d,"	//DCDC界面显示状态
					"ID_0x0393:%d," //PVS界面显示状态
					"ID_0x0394:%d," //BMS界面显示状态
					"ID_0x0395:%d," //电表界面显示状态
					"ID_0x0396:%d"  //实时监控界面显示状态 
			    "}",
                    get_param_by_id(0x0301,0),
					get_param_by_id(0x0390,0),
					get_param_by_id(0x0391,0),
					get_param_by_id(0x0392,0),
					get_param_by_id(0x0393,0),
					get_param_by_id(0x0394,0),
					get_param_by_id(0x0395,0),
					get_param_by_id(0x0396,0)
			);
            s_Rsc[0].size = strlen(s_000);
        break;
        case 15://PV信息
            sprintf(s_000,
                "HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n"
                "{"
                    "ID_0x0301:%d,"   //页面语言
                    "ID_0x0131:%d,"   //光伏逆变器直流电压1
                    "ID_0x0132:%d,"   //光伏逆变器直流电流1
                    "ID_0x0133:%d,"   //光伏逆变器直流电压2
                    "ID_0x0134:%d,"   //光伏逆变器直流电流2
                    "ID_0x0135:%d,"   //光伏逆变器电网电压VA
                    "ID_0x0136:%d,"   //光伏逆变器电网电压VB
                    "ID_0x0137:%d,"   //光伏逆变器电网电压VC
                    "ID_0x0138:%d,"   //光伏逆变器电网频率
                    "ID_0x0139:%d,"   //光伏逆变器有功功率
                    "ID_0x013A:%d,"   //光伏逆变器无功功率
                    "ID_0x013B:%d,"   //光伏逆变器功率因数
                    "ID_0x013C:%d,"   //光伏逆变器累计发电
                    "ID_0x013D:%d,"   //光伏逆变器工作状态
					"ID_0x013E:%d,"	  //光伏逆变器开关机状态
					"ID_0x013F:%d,"	  //光伏逆变器限功率开关状态
					"ID_0x0140:%d,"	  //光伏逆变器限功率值
					"ID_0x0130:%d,"	  //当前PV编号
					"ID_0x001B:%d"	  //PV总数
			    "}",
                    get_param_by_id(0x0301,Cur_PV_Num-1),
                    get_param_by_id(0x0131,Cur_PV_Num-1),
                    get_param_by_id(0x0132,Cur_PV_Num-1),
                    get_param_by_id(0x0133,Cur_PV_Num-1),
                    get_param_by_id(0x0134,Cur_PV_Num-1),
                    get_param_by_id(0x0135,Cur_PV_Num-1),
                    get_param_by_id(0x0136,Cur_PV_Num-1),
                    get_param_by_id(0x0137,Cur_PV_Num-1),
                    get_param_by_id(0x0138,Cur_PV_Num-1),
                    get_param_by_id(0x0139,Cur_PV_Num-1),
                    get_param_by_id(0x013A,Cur_PV_Num-1),
                    get_param_by_id(0x013B,Cur_PV_Num-1),
                    get_param_by_id(0x013C,Cur_PV_Num-1),
                    get_param_by_id(0x013D,Cur_PV_Num-1),
					get_param_by_id(0x013E,Cur_PV_Num-1),
					get_param_by_id(0x013F,Cur_PV_Num-1),
					get_param_by_id(0x0140,Cur_PV_Num-1),
                    get_param_by_id(0x0130,Cur_PV_Num-1),
                    get_param_by_id(0x001B,Cur_PV_Num-1)
			);
            s_Rsc[0].size = strlen(s_000);
        break;
        case 16://PVS信息
            sprintf(s_000,
                "HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n"
                "{"
                    "ID_0x0301:%d,"   //页面语言
                    "ID_0x0041:%d,"   //光伏汇流箱直流电压
                    "ID_0x0042:%d,"   //光伏汇流箱总电流
                    "ID_0x0043:%d,"   //光伏汇流箱直流输出功率
                    "ID_0x0044:%d,"   //光伏汇流箱每天输出功率
                    "ID_0x0045:%d,"   //光伏汇流箱总输出功率
					"ID_0x0046:%d,"	  //光伏汇流箱内部温度
					"ID_0x0047:%d,"	  //光伏汇流箱工作状态
					"ID_0x0040:%d,"	  //光伏汇流箱当前的编号
					"ID_0x001C:%d"    //光伏汇流箱总数
			    "}",
                    get_param_by_id(0x0301,Cur_PVS_Num-1),
                    get_param_by_id(0x0041,Cur_PVS_Num-1),
                    get_param_by_id(0x0042,Cur_PVS_Num-1),
                    get_param_by_id(0x0043,Cur_PVS_Num-1),
                    get_param_by_id(0x0044,Cur_PVS_Num-1),
					get_param_by_id(0x0045,Cur_PVS_Num-1),
					get_param_by_id(0x0046,Cur_PVS_Num-1),
					get_param_by_id(0x0047,Cur_PVS_Num-1),
                    get_param_by_id(0x0040,Cur_PVS_Num-1),	
                    get_param_by_id(0x001C,Cur_PVS_Num-1)
			);
            s_Rsc[0].size = strlen(s_000);
		break;
        case 17://DCDC信息
            sprintf(s_000,
                "HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n"
                "{"
                    "ID_0x0301:%d,"   //页面语言
		
                    "ID_0x0071:%d,"   //光伏控制器阵列电压(模块1)
                    "ID_0x0072:%d,"   //光伏控制器阵列电流(模块1)
                    "ID_0x0073:%d,"   //光伏控制器电池电压(模块1)
                    "ID_0x0074:%d,"   //光伏控制器充电电流(模块1)
                    "ID_0x0075:%d,"   //光伏控制器充电功率(模块1)
					"ID_0x0076:%d,"	  //光伏控制器机内温度(模块1)
					"ID_0x0077:%d,"	  //光伏控制器电池温度(模块1)
					"ID_0x0078:%d,"	  //光伏控制器设备状态(模块1)
		
                    "ID_0x0085:%d,"   //光伏控制器阵列电压(模块2)
                    "ID_0x0086:%d,"   //光伏控制器阵列电流(模块2)
                    "ID_0x0087:%d,"   //光伏控制器电池电压(模块2)
                    "ID_0x0088:%d,"   //光伏控制器充电电流(模块2)
                    "ID_0x0089:%d,"   //光伏控制器充电功率(模块2)
					"ID_0x008A:%d,"	  //光伏控制器机内温度(模块2)
					"ID_0x008B:%d,"	  //光伏控制器电池温度(模块2)	
					"ID_0x008C:%d,"	  //光伏控制器设备状态(模块2)
		
                    "ID_0x0099:%d,"   //光伏控制器阵列电压(模块3)
                    "ID_0x009A:%d,"   //光伏控制器阵列电流(模块3)
                    "ID_0x009B:%d,"   //光伏控制器电池电压(模块3)
                    "ID_0x009C:%d,"   //光伏控制器充电电流(模块3)
                    "ID_0x009D:%d,"   //光伏控制器充电功率(模块3)
					"ID_0x009E:%d,"	  //光伏控制器机内温度(模块3)
					"ID_0x009F:%d,"	  //光伏控制器电池温度(模块3)
					"ID_0x00A0:%d,"	  //光伏控制器设备状态(模块3)

                    "ID_0x00AD:%d,"   //光伏控制器阵列电压(模块4)
                    "ID_0x00AE:%d,"   //光伏控制器阵列电流(模块4)
                    "ID_0x00AF:%d,"   //光伏控制器电池电压(模块4)
                    "ID_0x00B0:%d,"   //光伏控制器充电电流(模块4)
                    "ID_0x00B1:%d,"   //光伏控制器充电功率(模块4)
					"ID_0x00B2:%d,"	  //光伏控制器机内温度(模块4)
					"ID_0x00B3:%d,"	  //光伏控制器电池温度(模块4)
					"ID_0x00B4:%d,"	  //光伏控制器设备状态(模块4)
					
					"ID_0x0070:%d,"	  //光伏控制器当前的编号
					"ID_0x001D:%d"    //光伏控制器总数					
			    "}",
					get_param_by_id(0x0301,Cur_DCDC_Num-1),
                    get_param_by_id(0x0071,Cur_DCDC_Num-1),
                    get_param_by_id(0x0072,Cur_DCDC_Num-1),
                    get_param_by_id(0x0073,Cur_DCDC_Num-1),
                    get_param_by_id(0x0074,Cur_DCDC_Num-1),
                    get_param_by_id(0x0075,Cur_DCDC_Num-1),
					get_param_by_id(0x0076,Cur_DCDC_Num-1),
					get_param_by_id(0x0077,Cur_DCDC_Num-1),	
					get_param_by_id(0x0078,Cur_DCDC_Num-1),	
					get_param_by_id(0x0085,Cur_DCDC_Num-1),
                    get_param_by_id(0x0086,Cur_DCDC_Num-1),
                    get_param_by_id(0x0087,Cur_DCDC_Num-1),
                    get_param_by_id(0x0088,Cur_DCDC_Num-1),
                    get_param_by_id(0x0089,Cur_DCDC_Num-1),
					get_param_by_id(0x008A,Cur_DCDC_Num-1),
					get_param_by_id(0x008B,Cur_DCDC_Num-1),	
					get_param_by_id(0x008C,Cur_DCDC_Num-1),	
					get_param_by_id(0x0099,Cur_DCDC_Num-1),
                    get_param_by_id(0x009A,Cur_DCDC_Num-1),
                    get_param_by_id(0x009B,Cur_DCDC_Num-1),
                    get_param_by_id(0x009C,Cur_DCDC_Num-1),
                    get_param_by_id(0x009D,Cur_DCDC_Num-1),
					get_param_by_id(0x009E,Cur_DCDC_Num-1),
					get_param_by_id(0x009F,Cur_DCDC_Num-1),
					get_param_by_id(0x00A0,Cur_DCDC_Num-1),
                    get_param_by_id(0x00AD,Cur_DCDC_Num-1),
                    get_param_by_id(0x00AE,Cur_DCDC_Num-1),
                    get_param_by_id(0x00AF,Cur_DCDC_Num-1),
                    get_param_by_id(0x00B0,Cur_DCDC_Num-1),
                    get_param_by_id(0x00B1,Cur_DCDC_Num-1),
					get_param_by_id(0x00B2,Cur_DCDC_Num-1),
					get_param_by_id(0x00B3,Cur_DCDC_Num-1),
					get_param_by_id(0x00B4,Cur_DCDC_Num-1),
                    get_param_by_id(0x0070,Cur_DCDC_Num-1),	
                    get_param_by_id(0x001D,Cur_DCDC_Num-1)
			);
            s_Rsc[0].size = strlen(s_000);
		break;
        case 18://BMS信息
            sprintf(s_000,
                "HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n"
                "{"
                    "ID_0x0301:%d,"   //页面语言
                    "ID_0x0051:%d,"   //BMS系统电压
                    "ID_0x0052:%d,"   //BMS 系统电流
                    "ID_0x0053:%d,"   //BMS 系统SOC
                    "ID_0x0054:%d,"   //BMS 系统SOH
					"ID_0x0050:%d,"	  //BMS当前的编号
					"ID_0x001E:%d"    //BMS总数
			    "}",
                    get_param_by_id(0x0301,Cur_BMS_Num-1),
                    get_param_by_id(0x0051,Cur_BMS_Num-1),
                    get_param_by_id(0x0052,Cur_BMS_Num-1),
                    get_param_by_id(0x0053,Cur_BMS_Num-1),
                    get_param_by_id(0x0054,Cur_BMS_Num-1),
					get_param_by_id(0x0050,Cur_BMS_Num-1),
					get_param_by_id(0x001E,Cur_BMS_Num-1)
			);
            s_Rsc[0].size = strlen(s_000);
		break;	
        case 19://系统参数
            /*sprintf(s_000,
                "HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n"
                "{"
                    "ID_0x0301:%d,"   //页面语言
                    "ID_0x0380:%d,"	  //协议选择
                    "ID_0x0381:%d,"   //母线类型
                    "ID_0x0382:%d,"   //是否并网
                    "ID_0x0383:%d,"   //直流母线充电使能
					"ID_0x0384:%d,"   //系统功率
					"ID_0x0385:%d,"   //储能逆变器型号
					"ID_0x0386:%d,"   //DCDC型号
					"ID_0x0387:%d,"   //优先级选择
					"ID_0x0388:%d,"   //VSG模式
					"ID_0x0390:%d,"	  //PCS从设备web界面是否显示
					"ID_0x0391:%d,"   //PV从设备web界面是否显示
					"ID_0x0392:%d,"   //DCDC从设备web界面是否显示
					"ID_0x0393:%d,"   //PVS从设备web界面是否显示
					"ID_0x0394:%d,"   //BMS从设备web界面是否显示
					"ID_0x0395:%d,"   //电表从设备web界面是否显示
					"ID_0x0396:%d"	  //实时监控界面是否显示
			    "}",
                    get_param_by_id(0x0301,0),
                    get_param_by_id(0x0380,0),
                    get_param_by_id(0x0381,0),
                    get_param_by_id(0x0382,0),
                    get_param_by_id(0x0383,0),
					get_param_by_id(0x0384,0),
					get_param_by_id(0x0385,0),
					get_param_by_id(0x0386,0),
					get_param_by_id(0x0387,0),
					get_param_by_id(0x0388,0),	
					get_param_by_id(0x0390,0),
					get_param_by_id(0x0391,0),
					get_param_by_id(0x0392,0),
					get_param_by_id(0x0393,0),
					get_param_by_id(0x0394,0),
					get_param_by_id(0x0395,0),
					get_param_by_id(0x0396,0)
			);*/
            s_Rsc[0].size = strlen(s_000);
		break;
        case 22://系统参数
            sprintf(s_000,
                "HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n"
                "{"
                    "ID_0x0301:%d,"   //页面语言
                    "ID_0x0380:%d,"	  //协议选择
                    "ID_0x0381:%d,"   //母线类型
                    "ID_0x0382:%d,"   //是否并网
                    "ID_0x0383:%d,"   //直流母线充电使能
					"ID_0x0385:%d,"   //储能逆变器型号
					"ID_0x0386:%d,"   //DCDC型号
					"ID_0x0387:%d"   //优先级选择
			    "}",
                    get_param_by_id(0x0301,0),
                    get_param_by_id(0x0380,0),
                    get_param_by_id(0x0381,0),
                    get_param_by_id(0x0382,0),
                    get_param_by_id(0x0383,0),
					get_param_by_id(0x0385,0),
					get_param_by_id(0x0386,0),
					get_param_by_id(0x0387,0)
			);
            s_Rsc[0].size = strlen(s_000);
		break;
        case 23://系统参数
            sprintf(s_000,
                "HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n"
                "{"
                    "ID_0x0301:%d,"   //页面语言
					"ID_0x0390:%d,"	  //PCS从设备web界面是否显示
					"ID_0x0391:%d,"   //PV从设备web界面是否显示
					"ID_0x0392:%d,"   //DCDC从设备web界面是否显示
					"ID_0x0393:%d,"   //PVS从设备web界面是否显示
					"ID_0x0394:%d,"   //BMS从设备web界面是否显示
					"ID_0x0395:%d,"   //电表从设备web界面是否显示
					"ID_0x0396:%d,"   //实时监控界面是否显示
					"ID_0x0388:%d,"   //VSG模式
					"ID_0x0389:%d,"	  //分时段控制使能
					"ID_0x038A:%d,"   //电池通讯选择
					"ID_0x038B:%d,"   //DCDC通讯使能
					"ID_0x038C:%d,"   //电表通讯使能
					"ID_0x038D:%d"    //BMS通讯使能
			    "}",
                    get_param_by_id(0x0301,0),
					get_param_by_id(0x0390,0),
					get_param_by_id(0x0391,0),
					get_param_by_id(0x0392,0),
					get_param_by_id(0x0393,0),
					get_param_by_id(0x0394,0),
					get_param_by_id(0x0395,0),
					get_param_by_id(0x0396,0),
					get_param_by_id(0x0388,0),
					get_param_by_id(0x0389,0),
					get_param_by_id(0x038A,0),
					get_param_by_id(0x038B,0),
					get_param_by_id(0x038C,0),
					get_param_by_id(0x038D,0)
			);
            s_Rsc[0].size = strlen(s_000);
		break;
        case 24://系统参数
            sprintf(s_000,
                "HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n"
                "{"
                    "ID_0x0301:%d,"   //页面语言
					"ID_0x0384:%d,"	  //系统功率匹配设置
			    "}",
                    get_param_by_id(0x0301,0),
					get_param_by_id(0x0384,0)
			);
            s_Rsc[0].size = strlen(s_000);
		break;	
        case 25://实时监控界面
			ptemp = strtok(data,delim);
			i=0;
			while(strcmp(ptemp,"time"))
			{
				if(i>=3) break;
				//调试寄存器1当前值
				ptemp = strtok(NULL,delim);
				reg[i++]=(uint16_t)atoi(ptemp);
			}
            sprintf(s_000,
                "HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n"
                "{"
                    "ID_0x0301:%d,"   //页面语言
					"ID_0x0290:%d,"	  //调试寄存器1
					"ID_0x0291:%d,"	  //调试寄存器2
					"ID_0x0292:%d"	  //调试寄存器3
			    "}",
                    get_param_by_id(0x0301,0),
					get_realtimedata_by_id(0x0290,reg[0]),
					get_realtimedata_by_id(0x0291,reg[1]),
					get_realtimedata_by_id(0x0292,reg[2])
			);
            s_Rsc[0].size = strlen(s_000);
		break;			
        default:
        break;
    }
}
void a_handler(int id,char* data)								//处理返回的参数，并回应
{
    char *ptemp;//切割出的内容
    char delim[] = "?=&+";//切割字符串
    uint32_t id_No=~0;//参数序号
    int32_t value=~0;//参数值
	uint8_t set_num=0;

    char login=~0;//修改密码时区分是超级密码还是普通密码进入来修改密码的。
    char login_c1=~0;//判断用户名和密码的标识
    char login_c2=~0;//判断用户名和密码的标识
    char login_s1=~0;//判断是否为超级密码登陆
    char login_s2=~0;//判断是否为超级密码登陆
	char login_setting2=~0;//判断是否是配置密码:7777
    char login1=~0;//判断是否是用户1登录
    char login2=~0;//判断是否是用户2登录
    static char flag=0;//密码确认还是修改密码
    int i=0;//用于复制密码的循环变量

    ptemp = strtok(data,delim);
    ptemp = strtok(NULL,delim);
    while(strcmp(ptemp,"time"))
    {
        if(!strcmp(ptemp,"0x0282"))//用户名确认
        {
            ptemp = strtok(NULL,delim);
            login1=strcmp(ptemp,"0");
            login2=strcmp(ptemp,"1");
        }
        else if(!strcmp(ptemp,"0x0283"))//密码确认
        {
            if(id==10)	//修改密码
            {
                if(SuperPwd==0x55)
                {
                    ptemp = strtok(NULL,delim);
                    if(userFlag==0x11)
                    {
                        while(*(ptemp+i)!='\0')
                        {
                            password[i]=*(ptemp+i);
                            i++;
                        }
                        password[i]='\0';
						(void)write_eeprom(WEBSERVER_PASSWORD_ADDRESS, password, 8);
                    }
                    else if(userFlag==0x22)
                    {
                        while(*(ptemp+i)!='\0')
                        {
                            password2[i]=*(ptemp+i);
                            i++;
                        }
                        password2[i]='\0';
						(void)write_eeprom(WEBSERVER_PASSWORD2_ADDRESS, password2, 8);
                    }
                    login=0;
                }
                else
                {
                    if(flag==0)
                    {
                        ptemp = strtok(NULL,delim);
                        if(userFlag==0x11)
                        {
                            if(SuperPwd==0x55)
                            {
                                login=0;
                            }
                            else
                            {
                                login=strcmp(ptemp,(char*)password);//判断密码
                            }
                        }
                        else if(userFlag==0x22)
                        {
                            if(SuperPwd==0x55)
                            {
                                login=0;
                            }
                            else
                            {
                                login=strcmp(ptemp,(char*)password2);//判断密码
                            }
                        }
                        if(login==0)flag=1;
                    }
                    else if(flag==1)//密码修改
                    {
                        flag=0;
                        ptemp = strtok(NULL,delim);
                        if(userFlag==0x11)
                        {
                            while(*(ptemp+i)!='\0')
                            {
                                password[i]=*(ptemp+i);
                                i++;
                            }
                            password[i]='\0';
							(void)write_eeprom(WEBSERVER_PASSWORD_ADDRESS, password, 8);
                        }
                        else if(userFlag==0x22)
                        {
                            while(*(ptemp+i)!='\0')
                            {
                                password2[i]=*(ptemp+i);
                                i++;
                            }
                            password2[i]='\0';
							(void)write_eeprom(WEBSERVER_PASSWORD2_ADDRESS, password2, 8);
                        }
                        login=0;
                    }
                }
            }
            else
            {
                ptemp = strtok(NULL,delim);
                if(login1==0)//用户1登陆
                {
                    login_c1=strcmp(ptemp,(char*)password);//根据用户名判断密码是否正确
                    login_s1=strcmp(ptemp,(char*)super_password);//密码都不正确，判断是否为超级密?
                    if(login_c1==0)
                    {
                        SuperPwd=0;
                    }
                    if(login_s1==0)//是使用超级密码登录的
                    {
                        SuperPwd=0x55;
                    }
                }
                else if(login2==0)
                {    
                    login_c2=strcmp(ptemp,(char*)password2);//同上
                    login_s2=strcmp(ptemp,(char*)super_password);//密码都不正确，判断是否为超级密码
					login_setting2=strcmp(ptemp,"7777");//判断是否是配置密码
                    if(login_c2==0)
                    {
                        SuperPwd=0;
                    }
                    if(login_s2==0)//是使用超级密码登录的
                    {
                        SuperPwd=0x55;
                    }
                }
            }
        }
        else if(!strcmp(ptemp,"feed"))//喂狗登录，将登录标识置4
        {
            ptemp = strtok(NULL,delim);
            loginFlag=(uint32_t)atoi(ptemp);
        }
		else
		{
			id_No=(uint16_t)strtoul(ptemp,0,16);
			ptemp = strtok(NULL,delim);
			value=(uint16_t)atoi(ptemp);
			set_param(set_num++,id_No,value);
		}
		ptemp = strtok(NULL,delim);
    }

    switch(id)
    {
        case 0:
            if(login1==0)//用户1的用户名正确
            {
                if(login_c1==0 || login_s1==0)//密码也正确
                {
                    if(loginFlag==0)//且无人登录
                    {   
						userFlag=0x11;//表示当前用户为"用户1"
						(void)write_eeprom(WEBSERVER_USERFLAG_ADDRESS, &userFlag, 1);
						loginFlag=2;//标识为已登录
						loginFlag2=2;//标识为已登录
						sprintf(a_000,"HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n%d",1);
                    }
                    else//但已经有人登录
                    {
						if(loginFlag2!=0)
						{
							sprintf(a_000,"HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n%d",1);
						}
						else
						{
							sprintf(a_000,"HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n%d",2);
						}
                    }
                }
                else//用户名正确，密码错误
                {
                    sprintf(a_000,"HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n%d",0);
                }
            }
            else if(login2==0)//用户2的用户名正确
            {
                if(login_c2==0 || login_s2==0  || login_setting2==0)//密码也正确
                {
                    if(loginFlag==0)//且无人登录
                    {
						if(login_setting2==0) loginFlag3=1;
						else loginFlag3=0;
						userFlag=0x22;//表示当前用户为"用户2"
						(void)write_eeprom(WEBSERVER_USERFLAG_ADDRESS, &userFlag, 1);
						loginFlag=2;//标识为已登录
						loginFlag2=2;//标识为已登录
						sprintf(a_000,"HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n%d",1);
                    }
                    else//但已经有人登录
                    {
						if(loginFlag2!=0)
						{
							sprintf(a_000,"HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n%d",1);
						}
						else
						{
							sprintf(a_000,"HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n%d",2);
						}
                    }
                }
                else//用户名正确，密码错误
                {
                    sprintf(a_000,"HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n%d",0);
                }
            }
		break;
        case 1:
            sprintf(a_000,"HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n%d",0);
		break;
        case 4:
        case 5:
        case 6:
            sprintf(a_000,"HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n%d",1);
        break;
        case 10:
            sprintf(a_000,"HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n%d",login?0:1);
        break;
        case 12:
		case 13:
		case 14:
		case 15:
		case 16:
		case 17:
		case 18:
		case 19:
		case 20:
		case 22:
		case 23:
		case 24:
		case 25:
            sprintf(a_000,"HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n%d",1);
        break;
        default:
            sprintf(a_000,"HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\nAccept-Ranges:bytes\r\n\r\n%d",0);
        break;
    }
    a_Rsc[0].size = strlen(a_000);
}
bool Leap_Year(int year)										//是否为闰年
{ 
	bool rtn = false;
    if ((year % 4 == 0 && year % 100 != 0 )|| year % 400 == 0) 
	{
        rtn = true;
	}
	else
	{
		rtn = false; 
	}
	return rtn;
} 
uint8_t How_Many_Day(int year,int month) 						//计算月发电量柱状图应该显示的天数
{
    uint8_t day=28;
    if(month==2)
    {
        if(Leap_Year(year)) day=29;
        else day=28;
    }
    else if(month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12)
        day=31;
    else if(month==4 || month==6 || month==9 || month==11)
        day=30;
    return day;
}
void r_handler(int id,char* data)								//导出历史记录（运行记录、故障记录）
{
    uint8_t run_buf[EVERY_RUNRECORD_BUF_LEN] = {0};
	int32_t records_num=0;//运行记录的条数
    LogTime time;
    char *ptemp;
    char delim[] = "?=&+";
    uint8_t page = 0;
	uint8_t array[16];
    ptemp = strtok(data,delim);
    ptemp = strtok(NULL,delim);
    ptemp = strtok(NULL,delim);
    time.Year = BinToBcd((uint8_t)(atoi(ptemp)-2000));
    ptemp = strtok(NULL,delim);
    ptemp = strtok(NULL,delim);
    time.Month = BinToBcd((uint8_t)atoi(ptemp));
    ptemp = strtok(NULL,delim);
    ptemp = strtok(NULL,delim);
    time.Date = BinToBcd((uint8_t)atoi(ptemp));
    ptemp = strtok(NULL,delim);
    ptemp = strtok(NULL,delim);
    page = atoi(ptemp);
    memset(jsCharts_temp,0,sizeof(jsCharts_temp));
    memset(p_000,0,sizeof(p_000));
    sprintf(p_000,"HTTP/1.1 200 OK\r\nContent-Type: application/octet-stream\r\n\r\n");
    
    switch(id)
    {
        case 7://运行记录
			records_num = start_query(E_RUNRECORD_LOG, &time, 1, run_buf, EVERY_RUNRECORD_BUF_LEN);
			if(records_num<=0)records_num=0;
            sprintf(jsCharts_temp,"{'R':[");
            strcat(p_000,jsCharts_temp);
            for(int i = (page-1)*10+1;page >= 1 && i<=(((page * 10) > records_num) ? records_num : (page * 10));i++)
            {
				query_rcd(i, run_buf, EVERY_RUNRECORD_BUF_LEN);
                sprintf(jsCharts_temp,"{");
                strcat(p_000,jsCharts_temp);
                //读失败就放前一条
                sprintf(jsCharts_temp,
                "'C1':%d,"
                "'C2':'%4d.%02d.%02d/%02d:%02d:00',"
                "'C3':%d,"					//运行状态
                "'C4':'%.1fV',"				//直流电压
                "'C5':'%.1fA',"				//直流电流
                "'C6':'%.1fkW',"			//直流功率
                "'C7':'%.1fV',"				//A相电压
                "'C8':'%.1fV',"				//B相电压
                "'C9':'%.1fV',"				//C相电压
                "'C10':'%.1fA',"			//A相电流
                "'C11':'%.1fA',"			//B相电流
                "'C12':'%.1fA',"			//C相电流
                "'C13':'%.1fkVA',"			//视在功率
                "'C14':'%.1fkW',"			//有功功率
                "'C15':'%.1fkVar',"			//无功功率
                "'C16':'%.2fHz',"			//电网频率
                "'C17':'%.3f',"				//功率因数
                "'C18':'%.1f&#176;C',"		//机内温度
                "'C19':'%.1f%%',"			//工作效率
                "'C20':'%.1fkWh',"			//日充电电量
                "'C21':'%.1fkWh',"			//日放电电量
                "'C22':'%dkWh',"			//总充电电量
                "'C23':'%dkWh',"			//总放电电量
                "'C24':'%dh'",				//总运行时间
                i,
                BcdToBin(run_buf[2])+2000,BcdToBin(run_buf[3]),
				BcdToBin(run_buf[4]),BcdToBin(run_buf[5]),BcdToBin(run_buf[6]),
				GetU16(run_buf+8),			//运行状态		2B
				GetU16(run_buf+10)/10.0,	//直流电压		2B
				GetU16(run_buf+12)/10.0,	//直流电流    	2B
				GetU32(run_buf+14)/1000.0,	//直流功率    	4B
				GetU32(run_buf+18)/10.0,	//A相电压    	4B
				GetU32(run_buf+22)/10.0,	//B相电压    	4B
				GetU32(run_buf+26)/10.0,	//C相电压    	4B
				GetU32(run_buf+30)/10.0,	//A相电流    	4B
				GetU32(run_buf+34)/10.0,	//B相电流    	4B
				GetU32(run_buf+38)/10.0,	//C相电流    	4B
				GetU32(run_buf+42)/1000.0,	//视在功率    	4B
				GetU32(run_buf+46)/1000.0,	//有功功率    	4B
				(int32_t)GetU32(run_buf+50)/1000.0,	//无功功率    	4B
				GetU16(run_buf+54)/100.0,	//电网频率    	2B
				(int32_t)GetU32(run_buf+56)/1000.0,	//功率因数    	4B
				(int16_t)GetU16(run_buf+60)/10.0,	//机内温度    	2B
				GetU16(run_buf+62)/10.0,	//工作效率    	2B
				GetU16(run_buf+64)/10.0,	//总充电电量    2B
				GetU16(run_buf+66)/10.0,	//总放电电量    2B
				GetU32(run_buf+68),			//总充电电量    4B
				GetU32(run_buf+72),			//总放电电量    4B
				GetU32(run_buf+76)			//总运行时间    4B
				);
                strcat(p_000,jsCharts_temp);
                sprintf(jsCharts_temp,"},");
                strcat(p_000,jsCharts_temp);
            }
            sprintf(jsCharts_temp,"{'end':0}]};Records=%d;",records_num);
            strcat(p_000,jsCharts_temp);
            p_Rsc[0].size = strlen(p_000);
            end_query();
            break;		
        case 8://事件记录
            sprintf(jsCharts_temp,"{'r':[");
            strcat(p_000,jsCharts_temp);
     
            for(int i=(page-1)*10+1; page >= 1 && i<=(((page*10)>read_event_record.total_nub)?read_event_record.total_nub:(page*10));i++)
            {
                Read_OnConditionNB_Record(read_event_record.ptr, read_event_record.total_nub,i,HISEVENTRECORD_START_ADDRESS,array) ;
                sprintf(jsCharts_temp,"{");
                strcat(p_000,jsCharts_temp);
                sprintf(jsCharts_temp,
                "'C1':%d,"
                "'C2':'%4d/%02d/%02d&nbsp;&nbsp;%02d:%02d:%02d',"
                "'C3':'%d'",
                i,
				BcdToBin(array[0])+2000,
				BcdToBin(array[1]),
				BcdToBin(array[2]),
				BcdToBin(array[3]),
				BcdToBin(array[4]),
				BcdToBin(array[5]),
				array[6]);
                strcat(p_000,jsCharts_temp);
                sprintf(jsCharts_temp,"},");
                strcat(p_000,jsCharts_temp);
            }
            sprintf(jsCharts_temp,"{'end':0}]};Records=%d;",read_event_record.total_nub);
            strcat(p_000,jsCharts_temp);
            p_Rsc[0].size = strlen(p_000);
        break;
        case 9://故障记录
            sprintf(jsCharts_temp,"{'r':[");
            strcat(p_000,jsCharts_temp);
     
            for(int i=(page-1)*10+1; page >= 1 && i<=(((page*10)>read_fault_record.total_nub)?read_fault_record.total_nub:(page*10));i++)
            {
				Read_OnConditionNB_Record(read_fault_record.ptr, read_fault_record.total_nub,i,HISFAULTRECORD_START_ADDRESS,array) ;
                sprintf(jsCharts_temp,"{");
                strcat(p_000,jsCharts_temp);
                sprintf(jsCharts_temp,
                "'C1':%d,"
                "'C2':'%4d/%02d/%02d&nbsp;&nbsp;%02d:%02d:%02d',"
                "'C3':'%d'",
                i,
				BcdToBin(array[0])+2000,
				BcdToBin(array[1]),
				BcdToBin(array[2]),
				BcdToBin(array[3]),
				BcdToBin(array[4]),
				BcdToBin(array[5]),
				array[6]);
                strcat(p_000,jsCharts_temp);
                sprintf(jsCharts_temp,"},");
                strcat(p_000,jsCharts_temp);
            }
            sprintf(jsCharts_temp,"{'end':0}]};Records=%d;",read_fault_record.total_nub);
            strcat(p_000,jsCharts_temp);
            p_Rsc[0].size = strlen(p_000);
        break;
        default:                                                                           
            p_000[0]=0;
            p_Rsc[0].size = 1;
        break;
    }
}
void his_handler(uint8_t type,char* data)						//导出历史记录
{
    uint8_t run_buf[EVERY_RUNRECORD_BUF_LEN] = {0};
	int32_t records_num=0;//运行记录的条数
	//const uint8_t minute[3]={0,20,40};
	uint8_t array[16]={0};
	//uint8_t month_day = 0;
	static char stemp[5];
	memset(stemp,0,sizeof(stemp));
	memcpy(stemp,data+21,4);
    R_time.Year = BinToBcd((uint8_t)(atoi(stemp)-2000));
	memset(stemp,0,sizeof(stemp));
	memcpy(stemp,data+26,2);
    R_time.Month = BinToBcd((uint8_t)atoi(stemp));
	memset(stemp,0,sizeof(stemp));
	memcpy(stemp,data+29,2);
    R_time.Date = BinToBcd((uint8_t)atoi(stemp));

	uint8_t temp=0;
	if(Webserver_Language!=0x55)
	{
		temp=1;
	}
    memset(p_000,0,sizeof(p_000));
    sprintf(p_000,"HTTP/1.1 200 OK\r\nContent-Type: application/octet-stream\r\n\r\n");
    switch(type)
    {
        case 6://运行信息
            sprintf(jsCharts_temp,"%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\r\n",
					Export_Name[0][temp],Export_Name[6][temp],Export_Name[7][temp],Export_Name[8][temp],Export_Name[9][temp],
					Export_Name[10][temp],Export_Name[11][temp],Export_Name[12][temp],Export_Name[13][temp],Export_Name[14][temp],
					Export_Name[15][temp],Export_Name[16][temp],Export_Name[17][temp],Export_Name[18][temp],Export_Name[19][temp],
					Export_Name[20][temp],Export_Name[21][temp],Export_Name[22][temp],Export_Name[23][temp],Export_Name[24][temp],
					Export_Name[25][temp],Export_Name[26][temp],Export_Name[27][temp],Export_Name[28][temp]);
            strcat(p_000,jsCharts_temp);
			
			records_num = start_query(E_RUNRECORD_LOG, &R_time, 1, run_buf, EVERY_RUNRECORD_BUF_LEN);
			if((records_num > 0) && (records_num < RUNRECORD_DAY_MAX_NUM))
			{
				for(uint8_t i=1;i<=records_num;i++)
				{
					query_rcd(i, run_buf, EVERY_RUNRECORD_BUF_LEN);
					sprintf(jsCharts_temp,
						"%d,"
						"%4d.%02d.%02d/%02d:%02d:00,"
						"%s,"						//运行状态
						"%.1fV,"					//直流电压
						"%.1fA,"					//直流电流
						"%.1fkW,"					//直流功率
						"%.1fV,"					//A相电压
						"%.1fV,"					//B相电压
						"%.1fV,"					//C相电压
						"%.1fA,"					//A相电流
						"%.1fA,"					//B相电流
						"%.1fA,"					//C相电流
						"%.1fkW,"					//视在功率
						"%.1fkW,"					//有功功率
						"%.1fkVar,"					//无功功率
						"%.2fHz,"					//电网频率
						"%.3f,"						//功率因数
						"%.1f°C,"				    //机内温度
						"%.1f%%,"					//工作效率
						"%.1fkWh,"					//日充电电量
						"%.1fkWh,"					//日放电电量
						"%dkWh,"					//总充电电量
						"%dkWh,"					//总放电电量
						"%dh\r\n",					//总运行时间
						i,
						BcdToBin(run_buf[2])+2000,BcdToBin(run_buf[3]),BcdToBin(run_buf[4]),BcdToBin(run_buf[5]),BcdToBin(run_buf[6]),
						Event_Name[GetU16(run_buf+8)][temp],//运行状态		2B
						GetU16(run_buf+10)/10.0,	//直流电压		2B
						GetU16(run_buf+12)/10.0,	//直流电流    	2B
						GetU32(run_buf+14)/1000.0,	//直流功率    	4B
						GetU32(run_buf+18)/10.0,	//A相电压    	4B
						GetU32(run_buf+22)/10.0,	//B相电压    	4B
						GetU32(run_buf+26)/10.0,	//C相电压    	4B
						GetU32(run_buf+30)/10.0,	//A相电流    	4B
						GetU32(run_buf+34)/10.0,	//B相电流    	4B
						GetU32(run_buf+38)/10.0,	//C相电流    	4B
						GetU32(run_buf+42)/1000.0,	//视在功率    	4B
						GetU32(run_buf+46)/1000.0,	//有功功率    	4B
						GetU32(run_buf+50)/1000.0,	//无功功率    	4B
						GetU16(run_buf+54)/100.0,	//电网频率    	2B
						GetU32(run_buf+56)/1000.0,	//功率因数    	4B
						GetU16(run_buf+60)/10.0,	//机内温度    	2B
						GetU16(run_buf+62)/10.0,	//工作效率    	2B
						GetU16(run_buf+64)/10.0,	//日充电电量    2B
						GetU16(run_buf+66)/10.0,	//日放电电量    2B
						GetU32(run_buf+68),			//总充电电量    4B
						GetU32(run_buf+72),			//总放电电量    4B
						GetU32(run_buf+76)			//总运行时间    4B
					);
					strcat(p_000,jsCharts_temp);
				}
			}
            end_query();
            p_Rsc[0].size =strlen(p_000);
		break;
        case 7://事件信息
			sprintf(jsCharts_temp,"%s,%s,%s\r\n",Event_Name[33][temp],Event_Name[34][temp],Event_Name[35][temp]);
			strcat(p_000,jsCharts_temp);
            for(int i=1;i <= read_event_record.total_nub;i++)
            {
				Read_OnConditionNB_Record(read_event_record.ptr, read_event_record.total_nub,i,HISEVENTRECORD_START_ADDRESS,array);
				
                sprintf(jsCharts_temp,"%02d,%04d.%02d.%02d/%02d:%02d:%02d,%s\r\n",
				i,
				BcdToBin(array[0])+2000,
				BcdToBin(array[1]),
				BcdToBin(array[2]),
				BcdToBin(array[3]),
				BcdToBin(array[4]),
				BcdToBin(array[5]),
				Event_Name[(uint8_t)array[6]][temp]);
                strcat(p_000,jsCharts_temp);
            }
            p_Rsc[0].size =strlen(p_000);
        break;
        case 8://故障信息
			sprintf(jsCharts_temp,"%s,%s,%s\r\n",Fault_Name[65][temp],Fault_Name[66][temp],Fault_Name[67][temp]);
			strcat(p_000,jsCharts_temp);
            for(int i=1;i <= read_fault_record.total_nub;i++)
            {
				Read_OnConditionNB_Record(read_fault_record.ptr, read_fault_record.total_nub,i,HISFAULTRECORD_START_ADDRESS,array);
				
                sprintf(jsCharts_temp,"%02d,%04d.%02d.%02d/%02d:%02d:%02d,%s\r\n",
				i,
				BcdToBin(array[0])+2000,
				BcdToBin(array[1]),
				BcdToBin(array[2]),
				BcdToBin(array[3]),
				BcdToBin(array[4]),
				BcdToBin(array[5]),
				Fault_Name[(uint8_t)array[6]][temp]);
                strcat(p_000,jsCharts_temp);
            }
            p_Rsc[0].size =strlen(p_000);
        break;
        default:            
            p_000[0]=0;
            p_Rsc[0].size = 1;
        break;
    }
}
